Use the for statement in a program that prints all the


Programming C++

Exercise

Exercise 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: You'll need to prompt for the two values; then, inside the for statement, initialize i to n1, and use n2 in the loop condition.)

Exercise 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 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.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Use the for statement in a program that prints all the
Reference No:- TGS02901367

Expected delivery within 24 Hours