Tuesday, 2 July 2013

c++ prog to print pyramid

/*
To Print Patterns (Pyramid)

   *
  * *
 * * *
* * * *
......
n......n


*/


#include<iostream.h>
#include<conio.h>
Void main()
{

clrscr();

cout<<"Enter the no of rows upto which pattern is to be printed";
cin>>n;

for(int i=1;i<=n;i++)
{
for(int j=1;j<=(n-i);j++)
{
cout<<" ";
}
for(int k=1;k<=i;k++)
{
cout<<"* ";
}
cout<<"/n";
}


getch();
}

No comments:

Post a Comment