Star Triangle
Completed
Read n and print a right triangle of stars: row i has i stars.
Input
One integer.
Output
n rows.
Example
Input
4
Output
* ** *** ****
Editor
C
Hints
The inner loop's limit depends on the outer loop variable.
Solution explanation
Nested loops: outer = rows, inner = characters in a row.
Show solution
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
for (int j = 0; j < i; j++) {
printf("*");
}
printf("\n");
}
return 0;
}