C++ Program to Print Right Arrow Star Pattern

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

#include<iostream>
using namespace std;

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

    cout << "Right Arrow Star Pattern\n"; 

    for(i = 0; i < rows; i++)
    {
    	for(j = 0; j < rows; j++)
		{
            if(j < i) {
                cout << " ";
            } 
            else {
                cout << "*";
            }    
        }
        cout << "\n";
    }	

    for(i = 2; i <= rows; i++)
    {
    	for(j = 0; j < rows; j++)
		{
            if(j < rows - i) {
                cout << " ";
            } 
            else {
                cout << "*";
            }
        }
        cout << "\n";
    }	
 	return 0;
}
CPP Program to Print Right Arrow Star Pattern

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

#include<iostream>
using namespace std;

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

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

    cout << "Right Arrow Star Pattern\n"; 

    while(i < rows)
    {
        j = 0; 
    	while(j < rows)
		{
            if(j < i) {
                cout << " ";
            } 
            else {
                cout << ch;
            }  
            j++;  
        }
        cout << "\n";
        i++;
    }

    i = 2;
    while( i <= rows)
    {
        j = 0;
    	while( j < rows)
		{
            if(j < rows - i) {
                cout << " ";
            } 
            else {
                cout << ch;
            }
            j++;
        }
        cout << "\n";
        i++;
    }	
 	return 0;
}
Enter Right Arrow Star Pattern Row = 12
Enter Symbol for Right Arrow Pattern = #
Right Arrow 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.