C++ Program to Print Natural Numbers in Reverse Order

C++ Program to Print Natural Numbers in Reverse Order

How to Print Natural Numbers from 1 to n in Reverse Order by C++? In C++ we can print n consecutive Natural Numbers by using Loops. Here in this program we used "while loop" to get our desired output.

Natural Numbers in Reverse Order by C++ :



#include <iostream>
using namespace std;

int main() 
{
    int n, i=1;
    
    cout << "Please Enter the range : ";
    cin >> n;
    cout << "The List of Natural Numbers from " << n << " to 1 are : ";

    while ( i <= n )
    {
        cout << n << " ";
        n--;
    }

    return 0;
}


Output :