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.
Enter how many rows you want : 5
1 2 3 4 5
1 2 3 4
1 2 3
Few browsers not showing the pattern properly, Here is the pattern in Image format.
Note : This program is one of theSeries of Number pattern programs in C.
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 :
// Enter the number of rows for your pattern
printf("Enter how many rows you want : ");
// As it is Inverted Pattern, We are going to start from the end
// i.e the loop start from the 'n' and comes down to 0
// We will print the number only if the j<=i
We used GNU GCC compiler to compile and run the program.
Similar Number Patterns:
Similar Star pattern programs :
- Basic star pattern program (The square pattern with stars).
- Triangle star pattern program.
- Triangle star pattern program with Spaces.
- Pyramid star pattern.
- Reverse Pyramid program.
- Diamond Star pattern program.
- star pattern program.
- K-Star pattern program.
- Empty Rhombus program.
- X-Star pattern program
- More Star Patterns