Blogger templates

Searching...
Wednesday, June 19, 2013

Printing Stars Make a Pyramid

12:24 PM
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;
}

1 comments: