Mirror Right Triangle Pattern
Mirror Right Triangle Pattern resemble a Right-Angled Triangle With the stars aligned to the right side of each row. However, unlike regular right triangle patterns where stars are aligned to the left, mirror right triangle patterns have stars aligned to the right. Each row has an increasing number of stars as it moves downwards, forming a triangular shape.
Output
Enter the number of rows: 5
*
**
***
****
*****
Free Hand-Written Notes
Codes – Mirror Right Triangle Pattern
#include <stdio.h> int main() { int rows, i, j; printf("Enter the number of rows: "); scanf("%d", &rows); for (i = 1; i <= rows; i++) { // Print spaces for (j = 1; j <= rows - i; j++) { printf(" "); } // Print stars for (j = 1; j <= i; j++) { printf("*"); } printf("\n"); } return 0; }
Codes Explanation
- The Codes Shows the Prompts to the user where user can enter the number of rows for the mirror right triangle.
- It iterates through each row using a
for
loop. - Within each row, it prints spaces using another nested
for
loop to align the stars to the right. Then it prints stars using another nestedfor
loop. - The number of stars in each row increases with the row number.