Feb 24, 2007

C program to generate a pyramid of stars

C program to generate pyramid of stars using for loop. In this program we use nesting of loop. Here two loops are used.
#include<stdio.h>
main()
{
int a,b,c;
a=1;
clrscr();
for (a=1;a<=5;a++)
{
for (b=1;b<=a;b++)
{
printf("*");
}
printf("\n");
}
getch();
}
//output would be
*
**
***
****
*****

No comments:

Post a Comment

Infolinks In Text Ads

Total Pageviews

Powered by Blogger.

Dont Forget To Follow Us

Blog Archive