C++ Program to Print Inverted Right Triangle of Same Column Numbers

Write a C++ program to print inverted right triangle of same column numbers using for loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, rows;
     
    cout << "Enter Inverted Right Triangle of Numbers Rows = ";
    cin >> rows;

    cout << "Inverted Right Triangle of Same Column Numbers Pattern\n";  

    for(i = rows; i >= 1; i--)
    {
    	for(j = 1; j <= i; j++)
		{
            cout << i << " ";
        }
        cout << "\n";
    }		
 	return 0;
}
C++ Program to Print Inverted Right Triangle of Same Column Numbers

This C++ example example prints the inverted right angled triangle of the same column numbers using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i, j, rows;
     
    cout << "Enter Inverted Right Triangle of Numbers Rows = ";
    cin >> rows;

    cout << "Inverted Right Triangle of Same Column Numbers Pattern\n";
    
    i = rows;

    while( i >= 1)
    {
        j = 1;
    	while( j <= i)
		{
            cout << i << " ";
            j++;
        }
        cout << "\n";
        i--;
    }		
 	return 0;
}
Enter Inverted Right Triangle of Numbers Rows = 8
Inverted Right Triangle of Same Column Numbers Pattern
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

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.