⭐⚡Beginner
Print Given Triangle
Print right-angled triangle
A right-angled triangle pattern is one of the simplest patterns. Each row contains an increasing number of stars, starting from 1.
Pattern Preview (5 rows):
* ** *** **** *****
C Program to Print Right Triangle
triangle.c
C
1#include <stdio.h>23int main() {4 int rows;5 6 printf("Enter number of rows: ");7 scanf("%d", &rows);8 9 for (int i = 1; i <= rows; i++) {10 // Print stars for each row11 for (int j = 1; j <= i; j++) {12 printf("*");13 }14 printf("\n");15 }16 17 return 0;18}Output
Enter number of rows: 5
*
**
***
****
*****
📖 How It Works
| Row (i) | Stars (j) | Output |
|---|---|---|
| 1 | 1 | * |
| 2 | 2 | ** |
| 3 | 3 | *** |
| ... | ... | ... |
🎯 Key Takeaways
✓Outer loop controls rows
✓Inner loop prints stars
✓Row i has i stars
✓Simplest pattern to learn
Related Examples
Want to Learn More?
Explore our comprehensive tutorials for in-depth explanations of C programming concepts.
Browse Tutorials