C++ Program to Print Right Triangle Star Pattern

Write a C++ program to print the right angled triangle star pattern using for loop.

#include<iostream>
using namespace std;

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

    cout << "Right Angled Triangle Star Pattern\n"; 

    for(i = 1; i <= rows; i++)
    {
    	for(j = 1; j <= i; j++)
		{
            cout << "* ";
        }
        cout << "\n";
    }		
 	return 0;
}
C++ Program to Print Right Triangle Star Pattern

This C++ example prints the right angled triangle pattern of a given character using a while loop.

#include<iostream>
using namespace std;

int main()
{
	int i = 1, j, rows;
    char ch;
     
    cout << "Enter Right Triangle Star Pattern Row = ";
    cin >> rows;

    cout << "Enter Symbol for Right Triangle Pattern = ";
    cin >> ch;

    cout << "Right Angled Triangle Star Pattern\n"; 

    while(i <= rows)
    {
        j = 1;
    	while(j <= i)
		{
            cout << ch << " ";
            j++;
        }
        cout << "\n";
        i++;
    }		
 	return 0;
}
Enter Right Triangle Star Pattern Row = 15
Enter Symbol for Right Triangle Pattern = $
Right Angled Triangle Star Pattern
$ 
$ $ 
$ $ $ 
$ $ $ $ 
$ $ $ $ $ 
$ $ $ $ $ $ 
$ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ 
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $

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.