- 1C Program - Print Simple Pyramid Pattern
- 2C Program - Print Given Triangle
- 3C Program - Print 180° Rotation of Simple Pyramid
- 4C Program - Print Inverted Pyramid
- 5C Program - Print Number Pattern
- 6C Character Pattern Program
- 7C Hollow Star Pyramid Pattern
- 8C Floyd's Triangle Program
- 9C Pascal's Triangle Program
C Program – Print Given Triangle - Right-Angled Star Pattern
Print Given Triangle
This pattern prints a left-aligned right-angled triangle using stars. The first row contains one star, the second row two stars, and so on up to the number of rows specified by the user. The pattern can be visualized as:
*
**
***
****
#include <stdio.h>
int main() {
int rows;
printf("Enter number of rows: ");
scanf("%d", &rows);
for (int i = 1; i <= rows; i++) {
for (int j = 1; j <= i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}
Enter number of rows: 4
*
**
***
****
The outer loop controls how many rows the triangle has, while the inner loop prints a number of stars equal to the current row number. After each row, a newline is printed to move to the next line.
⬅ Previous TopicC Program - Print Simple Pyramid Pattern
Next Topic ⮕C Program - Print 180° Rotation of Simple Pyramid
Next Topic ⮕C Program - Print 180° Rotation of Simple Pyramid
Comments
Loading comments...