subject

Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0 Show transcribed image text (1) Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:20
Write a select statement that returns product name, customer first name, customer last name, channel description, and amount sold for all the sales. make sure to returns sales even if there is no information on the customer, product, or channe
Answers: 2
question
Computers and Technology, 22.06.2019 18:30
What is outfitting a workplace with video in a technology
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
question
Computers and Technology, 24.06.2019 08:10
Where are american poets found in the dewey decimal system
Answers: 1
You know the right answer?
Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is o...
Questions
question
Computers and Technology, 21.12.2020 19:30
question
Mathematics, 21.12.2020 19:30
question
Advanced Placement (AP), 21.12.2020 19:30
question
Mathematics, 21.12.2020 19:30
question
Mathematics, 21.12.2020 19:30
Questions on the website: 13722361