C Example | Display Inverted Triangle Numbers Pattern

This c programming example code will introduce us how to display inverted triangle numbers pattern.

#include <stdio.h>

int main()
{
    int rows, i, j, k;

    printf("Enter Inverted Triangle Number Pattern Rows = ");
    scanf("%d", &rows);

    printf("Printing Inverted Triangle Number Pattern\n");
    i = 1;

    while (i <= rows)
    {
        j = 1;
        while (j < i)
        {
            printf(" ");
            j++;
        }

        k = 1;
        while (k <= rows - i + 1)
        {
            printf("%d ", k);
            k++;
        }
        printf("\n");
        i++;
    }
}

Run this code, we may see:

Enter Inverted Triangle Number Pattern Rows = 9
Printing Inverted Triangle Number Pattern
1 2 3 4 5 6 7 8 9 
 1 2 3 4 5 6 7 8 
  1 2 3 4 5 6 7 
   1 2 3 4 5 6 
    1 2 3 4 5 
     1 2 3 4 
      1 2 3 
       1 2 
        1