C++ Program to Print Hollow Inverted Right Triangle Star Pattern

Write a C++ program to print hollow inverted right triangle star pattern using for loop. 

#include<iostream>
using namespace std;

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

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

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

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

#include<iostream>
using namespace std;

int main()
{
	int i, j, rows;
    char ch;
     
    cout << "Enter Rows = ";
    cin >> rows;

    cout << "Enter Symbol = ";
    cin >> ch;
    
    i = rows;
    while( i > 0)
    {
        j = 1;
    	while( j <= i)
		{
            if(j == 1 || j == i || i == 1 || i == rows) 
            {
                cout << ch;
            }
            else
            {
                cout << " ";
            }   
            j++;      
        }
        cout << "\n";
        i--;
    }		
 	return 0;
}
Enter Rows = 15
Enter Symbol = $

$$$$$$$$$$$$$$$
$            $
$           $
$          $
$         $
$        $
$       $
$      $
$     $
$    $
$   $
$  $
$ $
$$
$