A program to print the format - column numbers pyramid
C Programming Language 046
The following code shows how to write a program to print the following format.
1
121
12321
1234321
Program
#include <stdio.h>
void main()
{
int i, j, k, l, space = 5;
{
for (i = 1; i <= 4; i++)
{
for (l = 1; l <= space; l++)
{
printf(" ");
}
space--;
for (j = 1; j <= i; j++)
{
printf("%d", j);
}
for (k = i - 1; k >= 1; k--)
{
printf("%d", k);
}
printf("\n");
}
}
printf("\n");
}
Result
1
121
12321
1234321
Last Updated on
Comments