Monday, May 16, 2016

Print Pyramid Using *




#include<stdio.h>
int main()
{
int len,i,j;
int count_a , count_b;

    printf("Enter Number Of Lines Of The Pyramid :\n");
    scanf("%d",&len);
    printf("\n");

    count_a = count_b = len-1;

    for(i=0; i<len; i++)
    {
        for(j=0; j<2*len-1; j++)
        {
            if(j>=count_a && j<=count_b)
                printf("*",j);
            else
                printf(" ");
        }
        count_a-- ,count_b++;

        printf("\n");
    }
    printf("\n\n");
    return 0 ;
}




Share this

0 Comment to "Print Pyramid Using *"

Post a Comment