- Write a program in C to print inverted right triangle star (*) pattern of n rows using for loop.
- Write a C program to print a inverted right angles triangle pattern of star (*) character using loops.

**INVERTED RIGHT TRIANGLE PATTERN**

#### Required Knowledge

**Algorithm to print inverted right triangle star pattern using loop**

*If you look closely, this pattern is the vertically inverted pattern of right triangle star pattern. As the row number increases from top to bottom, number of stars in a row decreases.*

- Take the number of rows(N) of inverted right triangle as input from user using scanf function.
**Number of stars in K**. In the pattern given above, N = 6. Hence, 1^{th}row is equal to (N - K + 1)^{st}row contains 6 star, 2^{nd}row contains 5 stars, 3^{rd}row contains 4 stars. In general, K^{th}row contains 6-k+1 stars.- We will use two for loops to print inverted right triangle star pattern.
- For a inverted right triangle star pattern of N rows, outer for loop will iterate N time. Each iteration of outer loop will print one row of the pattern.
- For K
^{th}row of inverted right triangle pattern, inner loop will iterate N-K+1 times. Each iteration of inner loop will print one star (*).

## C program to print inverted right triangle star pattern

#include<stdio.h> int main() { int i,j,rows; printf("Enter the number of rows\n"); scanf("%d", &rows); for(i = rows; i > 0; i--) { /* Prints one row of triangle */ for(j = i; j > 0; j--) { printf("* "); } /* move to next row */ printf("\n"); } return 0; }Output

Enter the number of rows 6 * * * * * * * * * * * * * * * * * * * * *

**Related Topics**