This simple program asks the user to input the lines or stage of a
pyramid. Then it will display the size and shape of the required
pyramid. If you don't understand any codes of the programs, Please
inform me & I will try my best to explain. Let's see the programs.
#include <stdio.h>
int main()
{
int ap, i, d=2,j;
int n;
printf("How many lines: ");
scanf("%d",&n);
for(i=0; i<n; i++)
{
ap = 1+(i)*d;
for(j=0; j<(n*2-ap)/2; j++)
printf(" ");
while(ap)
{
printf("*");
ap--;
}
printf("\n");
}
return 0;
}
$-)
ReplyDelete