Question: Step 1: Copy this program into your C++program editor, and compile it. Hopefully you will not get any error messages. Step 2: Run your program

 Step 1: Copy this program into your C++program editor, and compile

Step 1: Copy this program into your C++program editor, and compile it. Hopefully you will not get any error messages. Step 2: Run your program type in "5" to see what it prints. Notice that all of the output is on one line this time because we used spaces between the numbers, and the endl is printed after the for loop. The variable "num" declared in the for loop is only valid inside the loop itself. If we tried to print it out after the loop we would get a compiler error saying the variable is "out of scope". Step 3: Edit the program and add a second for loop to print out the EVEN numbers [0..input-1] on a single line. To do this, you need to modify the initialization, the logical expression, and the update variables code. You can use the same "cout" code as the first for loop. Step 4: Compile and test your program with a variety of input values. For example, if the user types in an 11, you should see: Enter a number: 11 10223446586107891011 Step 5: Edit your program again and add a third for loop to print the ODD numbers [input..1] on a single line. This problem is tricky because we are decreasing the numbers as we are printing, and we have to figure out the first value to print. If input is odd, we start by printing input. If input is even, we must start by printing input- 1. Step 6: Compile and test your program with a variety of input values. For example, if the user types in an 8 , you should see: Enter a number: 8 12345678 0246 7531 Step 7: Once you think your program is working correctly, upload your final program into the auto grader by following the instructions below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!