Sunday, February 14, 2021

Program to print inverted half pyramid using (*) star

Program to print inverted half pyramid using (*) star


#include<iostream.h>
#include<conio.h>
int main()
{
   int rows;
   cout<<"Enter number of rows :";
   cin>>rows;
   for(int i=rows; i>=1; --i)
   {
      for(int j=1; j<=i; ++j)
      {
        cout<<"*";
      }
   }
   getch();
}


Output : 


Enter number of rows :
4
* * * *
* * *
* *
*

No comments:

Post a Comment