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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started