C Program to Generate Numeric 1-121-12321 Pyramid Pattern

In this program, we generate pyramid like pattern using numbers. And numbers have pattern like this: 1 in first line, 121 in second line, 12321 in third line and so on.

Numeric Pyramid Pattern C Program


#include<stdio.h>

int main()
{
    int i,j,row;

    printf("Enter number of rows: ");
    scanf("%d",&row);

    for(i=1;i<=row;i++)
    {
        for(j=1;j<=row-i;j++)
        {
            printf(" ");
        }

        for(j=1;j<=i;j++)
        {
            printf("%d", j);
        }

        for(j=i-1;j>=1;j--)
        {
            printf("%d", j);
        }
        printf("\n");
    }

    return 0;
}

Output of above program

Enter number of rows: 8
       1
      121
     12321
    1234321
   123454321
  12345654321
 1234567654321
123456787654321