Pattern 31: C Program to print below number pattern using for loops

Program to print below Number Pattern :

Write a C Program to print the below Number pattern which looks like a triangle number pattern. The program should take the input from the user, The input number is going to be the number of rows which we are going to print in our pattern.

Before going to write the program, Let’s see how exactly pattern looks like for different input row values.

Example 1:

Enter how many rows you want : 5
 5
 4 5
 3 4 5
 2 3 4 5
 1 2 3 4 5

Example 2:

Enter how many rows you want : 10
10
9 10
8 9 10
7 8 9 10
6 7 8 9 10
5 6 7 8 9 10
4 5 6 7 8 9 10
3 4 5 6 7 8 9 10
2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10

Program Logic:

So if we observe above example patterns, We can see the pattern starts from the 'n' ( i.e row value)

At top row the pattern only have one value and then at second row it has two values, so on. and at the last row we have  'n' mber of values.

So we need two for loops. The outer for loop and Inner for loop.

  • The Outer or First for  loop ('i')  starts from the  'n'  and goes down to 1
  • The Inner for loop will always starts with  'i'  (which is the outer loop iterator) and At each iteration of outer for loop, The inner for loop will going to print the number value from  'i' to 'n'.

📢  This program is one of the Series of Number pattern programs in C.

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...

Leave a Reply