Write a program that does the following:
1. Initialize the variables.
2. Prompt the user to enter 20 numbers.
3. For each number in the list:
a. Get the next number.
b. Output the number (echo input).
c. If the number is even: {i. Increment the even count. ii. If the number is zero, increment the zero count. }otherwise, Increment the odd count.
4. Print the results.
1. You can initialize the variables zeros, evens, and odds when you declare them.
2. Use an output statement to prompt the user to enter 20 numbers.
3. For Step 3, you can use a for loop to process and analyze the 20 numbers.
In pseudocode, this step is written as follows: for (counter = 1; counter <= 20; counter++) { a. get the number; b. output the number; c. switch (number % 2) //check the remainder { case 0: increment the even count; if (number == 0) increment the zero count; break; case 1: case -1: increment the odd count; }//end switch }//end for 4. Print the result. Output the values of the variables zeros, evens, and odds.
Comments
Leave a comment