Example
Input :
Input rows: 5
Output :
***** * * * * * * *
Required Knowledge
Basic C++ programming, For loop, Nested loop, if-else
Program to print hollow inverted right triangle star pattern :
#include <iostream>using namespace std; int main(){ int i, j, rows; /* Input number of rows from user */ cout<<"Enter number of rows: "; cin>>rows; /* Iterate through rows */ for(i=1; i<=rows; i++) { /* Iterate through columns */ for(j=i; j<=rows; j++) { if(i==1 || j==i || j==rows) { cout<<"*"; } else { cout<<" "; } } /* Move to next line */ cout<<"\n"; } return 0; }