Home

A program to print the format - inverted column numbers triangle

C Programming Language 044

The following code shows how to write a program to print the following format.

4321
 321
  21
   1

Program

#include <stdio.h>

void main()
{
    int i, j, space = 0;
    {
        for (i = 4; i >= 1; i--)
        {
            for (j = 1; j <= space; j++)
            {
                printf(" ");
            }
            space++;
            for (j = i; j >= 1; j--)
            {
                printf("%d", j);
            }
            printf("\n");
        }
    }

    printf("\n");
}

Result

4321
 321
  21
   1


Last Updated on

Next Post: Rules vs Guidelines →

Comments