May 24, 2008

C++ Program for Pyramid of Stars (Upside down and Centered Aligned)














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

main()
{
clrscr();
int j=1;
for (int i=5;i>=1;i--)
{
for (int k=1;k<=j;k++)
{
cout << " ";
}
for (int x=1;x<=i;x++)
{
cout << " *";
}
cout <<endl;
j=j+1;
}
getch();
}
READ MORE - C++ Program for Pyramid of Stars (Upside down and Centered Aligned)

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();
}
READ MORE - C++ Program for Pyramid Of Stars (Centered Aligned)

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us