Thursday 9 May 2013

Pyramid-1


DESCRIPTION: This program prints the pyramid as below-
                                                                 1
                                                               232
                                                             34543
                                                           4567654


PROGRAM:


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


OUTPUT WINDOW:


No comments:

Post a Comment