pattern 25: C program to print 12345 number pattern ( Inverted triangle number pattern )

Inverted triangle number pattern Program:

Write a C Program to print the Inverted triangle number pattern using loops.

The program will take one input number from the user. Which is the number of rows for the pattern.

Here is an Example of desired pattern, When user input row size is 5.

Example:

Enter how many rows you want : 5

 1 2 3 4 5
 1 2 3 4
 1 2 3
 1 2
 1

Few browsers not showing the pattern properly, Here is the pattern in Image format.

Invarted-traingle-number-Pattern-in-c

Note : This program is one of theSeries of Number pattern programs in C.

Program Logic:

We are going to use the two for loops to create the pattern. The First for or Outer for loop is used to display the row numbers. And the second for loop or Inner for loop is useful to display the column numbers.

Here is the main logic

  • As it is Inverted Triangle pattern, Our outer for loop starts from the 'n' e input row size) and goes down upto the
    • At each iteration of outer loop, The inner loop goes from 1 to  'i'  ( Here  'i'  outer loop iterator).
    • So as we are stopping the iteration at 'i' e are creating the Triangle shape.

Inverted triangle number pattern Program : 

Venkatesh

Hi Guys, I am Venkatesh. I am a programmer and an Open Source enthusiast. I write about programming and technology on this blog.

You may also like...

6 Responses

  1. int main()
    {
    int i,j,k,n;
    printf("Enter how many rows you want : ");
    scanf("%d",&n);

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

    printf("n");
    }
    return 0;
    }

    Read more: http://www.sillycodes.com/2015/11/write-c-program-to-print-below-number-using-loops.html

  2. int main()
    {
    int i,j,k,n;
    printf("Enter how many rows you want : ");
    scanf("%d",&n);

    for(i=n;i>0;i–)
    {
    for(j=i;j<=n;j++)
    printf(" %d",j);

    printf("n");
    }
    return 0;
    }

    Read more: http://www.sillycodes.com/2015/11/pattern-31-c-program-to-print-below.html

  3. #include
    int main()
    {
    int i,j,k,n;
    printf("Enter how many rows you want : ");
    scanf("%d",&n);

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

    printf("n");
    }
    return 0;
    }

    Read more: http://www.sillycodes.com/2015/10/pattern-24-c-program-to-print-triangle-number-pattern.html

  4. Eniya Elango says:

    Pattern 7
    Write a program to print the given pattern.

    Input Format:
    Input consists of a single integer.

    Output Format:
    Refer sample output. There is a trailing space at the end of each line.

    Sample Input:
    5

    Sample Output:
    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5

  5. Eniya Elango says:

    Pattern 6
    Write a program to print the given pattern.

    Input Format:
    Input consists of a single integer.

    Output Format:
    Refer sample output. There is a trailing space at the end of each line.

    Sample Input:
    5

    Sample Output:
    5
    4 5
    3 4 5
    2 3 4 5
    1 2 3 4 5

  6. Eniya Elango says:

    Write a program to print the given pattern.

    Input Format:
    Input consists of a single integer.

    Output Format:
    Refer sample outputs. There is a trailing space at the end of each line.

    Sample Input:
    5

    Sample Output:
    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5

Leave a Reply