/* A program to print pyramid of numbers */
#include <stdio.h>
int main()
{
int n, c, k, start = 1, temp;
printf("Enter number of rows:");
scanf("%d",&n);
temp = n;
for ( c = 1; c <= n; c++ )
{
for ( k = temp; k > 1; k-- )
printf(" ");
temp--;
for ( k = 1; k <= 2*c - 1; k++ )
{
if ( k <= c)
{
printf("%d", start);
if ( k < c )
start++;
}
else
{
start--;
printf("%d", start);
}
}
start = 1;
printf("\n");
}
return 0;
}
#include <stdio.h>
int main()
{
int n, c, k, start = 1, temp;
printf("Enter number of rows:");
scanf("%d",&n);
temp = n;
for ( c = 1; c <= n; c++ )
{
for ( k = temp; k > 1; k-- )
printf(" ");
temp--;
for ( k = 1; k <= 2*c - 1; k++ )
{
if ( k <= c)
{
printf("%d", start);
if ( k < c )
start++;
}
else
{
start--;
printf("%d", start);
}
}
start = 1;
printf("\n");
}
return 0;
}