Pattern 29: C Program to print below triangle number pattern using loops

C Program to print number pattern 5:

Write a C program to print number pattern (5). We are going to use the two for loops to create the pattern.

The program will take the number of rows as the input and create the pattern upto the specified number of rows. Here are few sample expected outputs.

Example 1:

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

Example 2:

Enter how many rows you want : 7
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28

Example 3:

Enter how many rows you want : 10
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31 32 33 34 35 36
37 38 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55

Program Explanation:

If we see the given pattern,  We are basically counting the number of times we printed the a value. If you see at the first row, We printed 1. Then at second row we have 2 and 3. Which is also equal to the number of times we printed any number.

So it is basically counting the numbers.  We will maintain a  counter le to print the number.

Also Check:

Program to print number pattern : 

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