Question
Print a Pattern (Right-Angled Triangle) using for loop in C Language
Solution
✔ Verified
This C program prints a right-angled triangle pattern using nested for loops.
A right-angled triangle pattern consists of rows where each row contains an increasing number of symbols (such as asterisks *) starting from one up to the given number of rows.
The outer for loop controls the number of rows, while the inner for loop controls the number of symbols printed in each row. This pattern programming example helps beginners understand the use of nested loops and how to control output formatting in C.
#include <stdio.h>
int main() {
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
printf("* ");
}
printf("\n");
}
return 0;
}
Output:--
*
* *
* * *
* * * *
* * * * *
Click here to download practice questions on
For Loop In C