Floyd's triangle

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 <iostream>
#include <conio.h>

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<<j;//Display pattern
    }
    cout<<"\n";//move to next line
    }
    getch();
    return 0;
}

 

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 <iostream>
#include <conio.h>
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<<j<<" ";
    }
    cout<<"\n";//move to next line
    }
    getch();
    return 0;
}

When the above code is compiled and executed, it produces the following results

Enter the number of rows: 8
8
8 7 
8 7 6
8 7 6 5
8 7 6 5 4
8 7 6 5 4 3
8 7 6 5 4 3 2 
8 7 6 5 4 3 2 !

 

 

Pattern 3

Number pyramid pattern 1

Reverse order number pattern program 3

#include <iostream>
#include <conio.h>
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<<i<<" ";

           }
           cout<<"\n";//move to next line

           }
    return 0;
}

 

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

 

Similar post

Java program to print star pyramid pattern 

C program to print star pyramid pattern 

C++ program to print star pyramid pattern 

Python program to print star pyramid pattern 

Floyd’s triangle number pattern using for loop in C

Floyd’s triangle pattern using nested for loop in Java

Floyd’s triangle pattern using nested while loop in Java

Hollow pyramid triangle pattern in C++ language

Rhombus pattern in Java using for loop

Rhombus pattern in C using while loop

Rhombus pattern in C++ using do-while loop

 

Suggested for you

For loop in Java language

For loop in C++ language

For loop in C language

For loop in Python language

 

While loop in Java language

While loop in C language

While loop in C++ language

While loop in Python language

 

Do-while loop in Java language

Do-while loop in C language

Do-while loop in C++ language

 

Nested for loop in Java language

Nested for loop in C++ language

Nested for loop in C language

Nested for loop in Python language

 

Operator in C++ language

C program to reverse triangle number patterns using while loop
Reverse number pattern in Cpp using while loop
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

View Comments

Recent Posts

Explanation of one dimensional array (Data structure)

Explanation of one dimensional array In this post, we will discuss the concept of "Explanation…

2 days ago

Python program to calculate the sum of odd and even numbers in a list

Python program to calculate the sum of odd and even numbers in a list In…

5 days ago

Python code to Calculate sum of odd and even in a list

Python code to Calculate sum of odd and even in a list In this tutorial,…

1 week ago

How to find reverse number using method in Java

How to find reverse number using method In this article, we will discuss the concept…

2 weeks ago

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

1 month ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

2 months ago