5. if and for Statements
Counting Backwards
What follows is a program that prints out the first five natural numbers backwards, that is from the greatest number towards the smallest:
#include <iostream> using namespace std; int main() { for(double i=1;i<=5;i++) cout << 6-i << endl; }
Upon execution, this program results in the following output:
5 4 3 2 1
Exercise: Modify this program so that it prints out the first 100 natural numbers, ordered backwards.