Q:

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

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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:

Enter any number: 

10

10987654321

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write C++ program to print sum of digits enter by ... >>
<< Write C++ program to print multiplication table of...