Write C++ program to print all natural numbers in reverse order

Introduction

I have used CodeBlocks compiler for debugging purpose. But you can use any C++ programming language compiler as per your availability.

#include <iostream>
using namespace std;
 
int main()
{
    int num=0, i;
 
   //Reading number
    cout<<"Enter any number: "<<endl;
    cin>>num;
    /*Running loop from the number entered by user,
      and Decrementing by 1*/
    for(i=num; i>=1; i--)
    {
        cout<<i;
    }
    return 0;
 
}

Result

Write C++ program to print all natural numbers in reverse order
Write C++ program to print all natural numbers in reverse order

Leave a Comment