Question: Programming C++ Exercise 4.1 Exercise 4.1.1. Use the for statement in a program that prints all the numbers from n1 to n2, where n1 and

Programming C++

Exercise 4.1

Exercise 4.1.1. Use the for statement in a program that prints all the numbers from n1 to n2, where n1 and n2 are two numbers specified by the user. (Hint: Youll need to prompt for the two values; then, inside the for statement, initialize i to n1, and use n2 in the loop condition.)

Exercise 4.1.2. Rewrite the example so that it prints all the numbers from n to 1 in reverse order. For example, the user enters 5, and the program prints 5 4 3 2 1. (Hint: In the for loop, initialize i to n, use the condition i >= 1, and subtract 1 from i in the increment step.)

Exercise 4.1.3. Write a program that prints all numbers from 1 to n, but prints only even numbers or only odd numbers. Each number printed will be 2 higher than the last

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!