- 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.

#### 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.*

NOTE: The index of rows and columns starts from 0.

NOTE: The index of rows and columns starts from 0.

- 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 = 7. Hence, 1^{th}row is equal to (N - K + 1)^{st}row contains 7 star, 2^{nd}row contains 6 stars, 3^{rd}row contains 5 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(from i = 0 to N-1). Each iteration of outer loop will print one row of the pattern.
- For j
^{th}row of inverted right triangle pattern, inner loop will iterate N-j times(from j = 0 to N-j). Each iteration of inner loop will print one star character.

Here is the matrix representation of the inverted right triangle star pattern. The row numbers are represented by i whereas column numbers are represented by j.

## 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 = 0; i < rows; i++) { /* Prints one row of triangle */ for(j = 0; j < rows - i; j++) { printf("* "); } /* move to next row */ printf("\n"); } return 0; }Output

Enter the number of rows 7 * * * * * * * * * * * * * * * * * * * * * * * * * * * *

**Related Topics**