Reverse order number pattern in Cpp using for loop
In this tutorial, we will discuss a concept of Reverse order number pattern in Cpp using for loop
In C++ language, we can use for loop, while loop, do-while loop to display various number, star, alphabet and binary number patterns
In this topic, we demonstrate how to display some reversed number patterns using the nested for loop in Cpp language.
Pattern 1
Reversed number pattern 1
Reverse order number pattern program 1
#include
#include
using namespace std;
int main()
{
int i,j,rows;//variable declaration
cout<<"Enter the number of rows: ";
cin>>rows;//Take input the number of rows from user
cout<<"\n";
for(i=1; i<=rows; i++){
for(j=i; j>=1; j--){
cout<
When the above code is compiled and executed, it produces the following results
Enter the number of rows: 8
1
21
321
4321
54321
654321
7654321
87654321
Program 2
Reversed number pattern 2
Reverse order number pattern program 2
#include
#include
using namespace std;
int main()
{
int i,j,rows;//variable declaration
cout<<"Enter the number of rows: ";
cin>>rows;//Take input the number of rows from user
for( i=rows; i>=1; i--){
for( j=rows; j>=i; j--){
cout<
When the above code is compiled and executed, it produces the following results
#include
#include
using namespace std;
int main()
{
int i,j,rows;//variable declaration
cout<<"Enter the number of rows: ";
cin>>rows;//Take input the number of rows from user
for(i=rows; i>=1; i--){//outer loop
for(j=i; j>=1; j--){//inner loop
cout<
When the above code is compiled and executed, it produces the following results
Enter the number of rows: 7
7 7 7 7 7 7 7
6 6 6 6 6 6
5 5 5 5 5
4 4 4 4
3 3 3
2 2
1
No Comments
muhammad December 6, 2022 at 7:11 pm
Thank you so much you save my life….