Left Triangle Star Pattern
Left Triangle Star Pattern resemble a Right-Triangle Star Pattern with the stars aligned to the left side of the each row. Each row has an increasing number of stars as it moves downwards, forming a triangular shape.
Output
Enter the number of rows: 5
*
* *
* * *
* * * *
* * * * *
C Language Free Notes
Codes for Left Triangle Star Pattern
Here are the codes of Left Triangle Star Pattern,1.
#include <stdio.h> int main() { int rows, i, j; printf("Enter the number of rows: "); scanf("%d", &rows); for (i = 1; i <= rows; i++) { for (j = 1; j <= i; j++) { printf("* "); } printf("\n"); } return 0; }
Code Explanation
- The Code Shows the Prompt to the user for enter the number of rows for the left triangle.
- It iterates through each row using a
for
loop. Within each row, it prints stars using another nestedfor
loop. - The number of stars in each row increases with the row number.