Header Ads

How to print given Pyramid in C

-----------------------------------------------Program--------------------------------------

#include<stdio.h>
#include<conio.h>
main()
{
    int r,c,n,d=0;
    printf("Enter the numbers of row: ");
    scanf("%d",&n);
    d=n;
    for(r=0;r<=n-1;r++)
    {
        d=d-r;
        for(c=n-r;c>=1;c--)
        {
            printf("%d",d);
        }
        d=n;
        printf("\n");
    }
    getch();
}


-----------------------------------------------Output----------------------------------------

screenshot for above pyramid program

No comments