Program to print full pyramid using star (*)
#include<iostream.h>
#include<conio.h>
int main()
{
int space,rows;
cin>>rows;
for(int i=1, k=0; i<=rows; ++i,k=0)
{
for(space=1; space<=rows-i; ++space)
{
cout<<" ";
}
while(k !=2*i-1)
{
cout<<"*"; ++k;
}
cout<<endl;
}
getch();
}
Output :
Enter number of rows : 3
*
***
*****
No comments:
Post a Comment