May 24, 2008

C++ Program for Pyramid Of Stars (Centered Aligned)

















#include<iostream.h>
#include<conio.h>

main()
{
clrscr();
int j=5;

for (int i=1;i<=5;i++)
{
for (int k=1;k<=j;k++)
{
cout << " ";
}
for (int x=1;x<=i;x++)
{
cout << "*";
cout << " ";
}
cout <<endl;
j=j-1;
}
getch();
}

No comments:

Post a Comment