DESCRIPTION: This program prints the pyramid as below-
1
121
12321
1234321
PROGRAM:
#include<stdio.h>
main()
{
int i,j,k,n,m;
printf("enter no. of lines\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(m=0;m<n-i;m++)
printf(" ");
for(j=0,k=i;j<=i||k!=0;j++)
{
if(j<=i)
printf("%d",j+1);
else if(k!=0)
{
printf("%d",k--);
}
}
printf("\n");
}
}
No comments:
Post a Comment