Monday, February 8, 2021

Program to print half Pyramid using star (*) using C++

Program to print half  Pyramid using star (*)



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


Output :


Enter the number of rows : 4

*
* *
* * *
* * * *

No comments:

Post a Comment