Encoders
>
More...
>
C
>
Program
/* Program to form a pyramid of numbers. */
#include <stdio.h>
main()
{
int i,j,n;
printf("Enter the number of rows: ");
scanf("%d",&n);
if(n<1||n>9)
printf("Invalid Argument\n");
else
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
printf(" ");
for(j=1;j<1+i;j++)
printf("%d",j);
for(;j>0;j--)
printf("%d",j);
printf("\n");
}
}
|