C Exercises: Display the pattern like right angle triangle with number increased by 1
12. Right Angle Triangle with Sequentially Increasing Numbers
Write a program in C to make such a pattern like a right angle triangle with the number increased by 1.
The pattern is as follows :
1 2 3 4 5 6 7 8 9 10
This C program generates a right-angle triangle pattern where each row displays numbers incrementally starting from 1 and increasing by 1 in each subsequent row. It employs nested loops to control the number of rows and the numbers displayed in each row, creating the desired pattern. This problem highlights the use of nested loops and pattern formation techniques in C programming.
Visual Presentation:

Sample Solution:
C Code:
Output:
Input number of rows : 4 1 2 3 4 5 6 7 8 9 10
Explanation:
for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) printf("%d ", k++); printf("\n"); }
In the above loop, the variable i is initialized to 1, and the loop will continue as long as i is less than or equal to the value of variable 'rows'. In each iteration of the outer loop, another loop is started with variable j, initialized to 1, and it will continue as long as j is less than or equal to the value of i.
In each iteration of the inner loop, the printf function will print the value of k to the console, followed by a space character. The value of k will be incremented by 1 in each iteration of the inner loop using the postfix increment operator (k++), so that each value printed is unique.
After the inner loop completes, the outer loop will print a newline character (\n) to create a new line.
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to display a right angle triangle where each row starts with 1 and resets to 1 on each new line.
- Write a C program to display a right angle triangle with consecutive numbers starting from a user-defined value.
- Write a C program to print a triangle pattern where the last number of one row becomes the first of the next row.
- Write a C program to display a right angle triangle with sequential numbers and then calculate the sum of numbers in each row.
C Programming Code Editor:
Previous: Write a program in C to make such a pattern like right angle triangle with a number which will repeat a number in a row.
Next: Write a program in C to make such a pattern like a pyramid with numbers increased by 1.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics