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