Thursday 9 May 2013

Inverted pyramid-1


DESCRIPTION: To print the inverted pyramid pattern as below-
                                                                 1234321
                                                                   12321
                                                                     121
                                                                       1


PROGRAM:


#include<stdio.h>
main()
{
    int i,j,k,l,n;
    printf("enter the value of n\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        for(j=n-i;j<n;j++)
        printf(" ");
        for(k=1;k<=n-i;k++)
        printf("%d",k);
        for(l=n-i-1;l>0;l--)
        printf("%d",l);
        printf("\n");
    }
}


OUTPUT WINDOW:


No comments:

Post a Comment