Question #184541

Write a C++ program to print all natural numbers in reverse (from n to 1). - using while loop


Expert's answer

#include <iostream>


using namespace std;


int main()
{
    cout << "n = ";
    int n;


    cin >> n;


    while(n > 0)
    {
        cout << n << " ";
        n--;
    }
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS