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

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

#include<iostream>
using namespace std;

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

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

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

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

#include<iostream>
using namespace std;

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

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

    i = rows;

    while( i >= 1)
    {
        j = 1;

    	while( j <= i)
		{
            cout << j << " ";
            j++;
        }
        cout << "\n";
        i--;
    }		
 	return 0;
}
Enter Inverted Right Triangle of Consec Col Numbers Rows = 15
Inverted Right Triangle of Consecutive Column Numbers Pattern
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 
1 2 3 4 5 6 7 8 9 10 11 12 13 
1 2 3 4 5 6 7 8 9 10 11 12 
1 2 3 4 5 6 7 8 9 10 11 
1 2 3 4 5 6 7 8 9 10 
1 2 3 4 5 6 7 8 9 
1 2 3 4 5 6 7 8 
1 2 3 4 5 6 7 
1 2 3 4 5 6 
1 2 3 4 5 
1 2 3 4 
1 2 3 
1 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.