A program to print the format - stars/asterisks pyramid
C Programming Language 047
The following code shows how to write a program to print the following format.
*
***
*****
*******
Program
#include <stdio.h>
void main()
{
int i, j, k, l, space = 5;
{
for (i = 1; i <= 4; i++)
{
for (l = 1; l <= space; l++)
{
printf(" ");
}
space--;
for (j = 1; j <= i; j++)
{
printf("*");
}
for (k = i - 1; k >= 1; k--)
{
printf("*");
}
printf("\n");
}
}
printf("\n");
}
Result
*
***
*****
*******
Last Updated on
Comments