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

Write a C++ program to print the hollow inverted right angled 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 Hollow Inverted Right Triangle Star pattern Rows = ";
    cin >> rows;

    cout << "Enter Symbol for Hollow Inverted Right Triangle pattern = ";
    cin >> ch;

    cout << "Hollow Inverted Right Angled Triangle Star Pattern\n"; 
    
    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 Hollow Inverted Right Triangle Star pattern Rows = 15
Enter Symbol for Hollow Inverted Right Triangle pattern = $
Hollow Inverted Right Angled Triangle Star Pattern
$$$$$$$$$$$$$$$
$            $
$           $
$          $
$         $
$        $
$       $
$      $
$     $
$    $
$   $
$  $
$ $
$$
$