Floyd's triangle

Reverse number pattern in Cpp using while loop

Reverse number pattern in Cpp using while loop

In this tutorial, we will discuss Reverse number pattern in Cpp using while 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 while loop in Cpp language.

pattern 1

Reverse pyramid pattern 1

Reverse number pattern program  1

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int j,rows;//variable declaration
    cout<<"Enter the number of rows: ";
    cin>>rows;//take input from user for rows
    cout<<"\n";//move to next line

    while(rows>=1){
        int j=rows;
        while(j>=1){
           cout<<j<<" ";
            j--;
        }
        rows--;
    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 7 6 5 4 3 2 1
7 6 5 4 3 2 1
6 5 4 3 2 1
5 4 3 2 1
4 3 2 1
3 2 1
2 1 
1

 

Pattern 1

Reverse number pattern 2

 

Reverse number pattern program 2

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int j,rows;//variable declaration
    cout<<"Enter the number of rows: ";
    cin>>rows;//take input from user for rows
    cout<<"\n";//move to next line
int i;
    while(rows>=0){
        for(i=1; i<=rows; i++){
            cout<<rows<<" ";
        }
        rows--;
    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 8 8 8 8 8 8 
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

 

Reverse order number pattern in Cpp using for loop
C program to display alphabet pattern
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.

Recent Posts

How to find reverse number using method in Java

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

20 hours ago

C# inverted full pyramid star pattern

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

3 weeks ago

C# Full Pyramid star pattern program

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

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago