# C program to print right triangle star pattern

• Write a program in C to print right triangle star (*) pattern of n rows using for loop.
• Write a C program to print a right angles triangle pattern of star (*) character using loops.
For a right triangle star pattern of 7 rows. Program's output should be:

### RIGHT TRIANGLE STAR PATTERN #### Required Knowledge

Algorithm to print right triangle star pattern using loop
• Take the number of rows(N) of right triangle as input from user using scanf function.
• Number of stars in Kth row is always K. 1st row contains 1 star, 2nd row contains 2 stars, 3rd row contains 3 stars. In general, Kth row contains K stars.
• We will use two for loops to print right triangle star pattern.
• For a 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 Kth row of right triangle pattern, inner loop will iterate K times. Each iteration of inner loop will print one star (*).

## C program to print right triangle star pattern

```#include<stdio.h>
#include<conio.h>

int main() {
int i,j,rows;
printf("Enter the number of rows\n");
scanf("%d", &rows);

for(i = 1; i <= rows; i++) {
/* Prints one row of triangle */
for(j = 1; j <= i; ++j) {
printf("* ");
}
/* move to next row */
printf("\n");
}
getch();
return 0;
}
```
Output
```Enter the number of rows
6
*
* *
* * *
* * * *
* * * * *
* * * * * *
```

Related Topics
 C program binary triangle pattern C program palindrome triangle pattern C program natural number triangle pattern C program pyramid star pattern C program diamond star pattern C program inverted right triangle pattern C program heart shape star pattern C program mirrored right triangle star pattern C program exponentially increasing star pattern List of all C pattern programs