C++ Program to Print First 10 Natural Numbers in Reverse

Write a C++ program to print first 10 natural numbers in reverse order using for loop.

#include<iostream>
using namespace std;

int main()
{
	cout << "The First 10 Natural Numbers in Reverse\n";

	for (int i = 10; i >= 1; i--)
	{
		cout << i << "\n";
	}
}
C++ Program to Print First 10 Natural Numbers in Reverse

C++ program to print first 10 natural numbers in reverse using a while loop

#include<iostream>
using namespace std;

int main()
{
	int i = 10;

	cout << "The First 10 Natural Numbers in Reverse\n";
	while (i >= 1)
	{
		cout << i << "\n";
		i--;
	}
}
The First 10 Natural Numbers in Reverse
10
9
8
7
6
5
4
3
2
1

This C++ program uses the do while loop and displays the first 10 natural numbers in the reverse or descending order.

#include<iostream>
using namespace std;

int main()
{
	int i = 10;

	cout << "The First 10 Natural Numbers in Reverse\n";

	do
	{
		cout << i << "\n";

	} while (--i >= 1);
}
The First 10 Natural Numbers in Reverse
10
9
8
7
6
5
4
3
2
1

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.