C++ Program to Print Right Triangle of Incremented Numbers

Write a C++ program to print the right triangle of incremented numbers pattern using for loop.

#include<iostream>
using namespace std;

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

    cout << "Right Angled Triangle of Incremenetd Numbers Pattern\n"; 

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

This C++ example prints the incremented numbers in a right angled triangle pattern using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i = 1, j, rows;
     
    cout << "Enter Right Triangle Incremented Numbers Row = ";
    cin >> rows;

    cout << "Right Angled Triangle of Incremenetd Numbers Pattern\n"; 

    while(i <= rows)
    {
        j = i;
    	while( j >= 1)
		{
            cout << j << " ";
            j--;
        }
        cout << "\n";
        i++;
    }		
 	return 0;
}
Enter Right Triangle Incremented Numbers Row = 12
Right Angled Triangle of Incremenetd Numbers Pattern
1 
2 1 
3 2 1 
4 3 2 1 
5 4 3 2 1 
6 5 4 3 2 1 
7 6 5 4 3 2 1 
8 7 6 5 4 3 2 1 
9 8 7 6 5 4 3 2 1 
10 9 8 7 6 5 4 3 2 1 
11 10 9 8 7 6 5 4 3 2 1 
12 11 10 9 8 7 6 5 4 3 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.