Full Pyramid Number Pattern in C

In this tutorial, we will write a C Program to display Pyramid patterns using numbers. Before that, you may go through the following topic in C.

Full Pyramid Number Pattern in C

1. Full pyramid with mirror pattern of numbers.

#include <stdio.h>

int main()
{
  int i, j, rows, k = 0, count1 = 0, count2 = 0;

  printf("Enter the no of rows: ");
  scanf("%d", &rows);

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

    while (k != 2 *i - 1)
    {
      if (count1 <= rows - 1)
      {
        printf("%d ", i + k);
        ++count1;
      }
      else
      {
        ++count2;
        printf("%d ", (i + k - 2 *count2));
      }

      ++k;
    }

    count2 = count1 = k = 0;
    printf("\n");
  }

  return 0;
}
Enter the no of rows: 6
          1 
        2 3 2 
      3 4 5 4 3 
    4 5 6 7 6 5 4 
  5 6 7 8 9 8 7 6 5 
6 7 8 9 10 11 10 9 8 7 6 

2. Full pyramid with repeating pattern of numbers.

#include <stdio.h>

int main()
{
  int rows, count = 1;

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

  for (int i = rows; i > 0; i--)
  {
    for (int j = 1; j <= i; j++)
      printf(" ");

    for (int j = 1; j <= count; j++)
      printf("%d ", count);

    printf("\n");

    count++;
  }

  return 0;
}
Enter the number of rows: 6
      1 
     2 2 
    3 3 3 
   4 4 4 4 
  5 5 5 5 5 
 6 6 6 6 6 6 

3. Full pyramid pattern of numbers.

#include <stdio.h>

int main()
{
  int rows, count = 1;

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

  for (int i = rows; i > 0; i--)
  {
    for (int j = 1; j <= i; j++)
      printf(" ");

    for (int j = 1; j <= count; j++)
      printf("%d ", j);

    printf("\n");

    count++;
  }

  return 0;
}
Enter the number of rows: 6
      1 
     1 2 
    1 2 3 
   1 2 3 4 
  1 2 3 4 5 
 1 2 3 4 5 6