Outer for loop goes from i = 1 to n
Inner for loop goes from j = 0 to i
Show us an attempt of you trying it yourself.
_____
Edit: I misread the problem. Having the total number of stars as input doesn't make much sense. Show us what the output should look like for, say, n = 7.
Should it look like
and they did not say what to do when it does not make sense?
simple things, do what you can (as above, stop when hit # of stars) or drop the last row (don't use all the stars asked for is ok??) or... you can do something fancy, like find the # of rows you can do correctly, figure out how many you have left over, and insert the row that holds that many a second time.
eg for 7, 6 makes 3 rows, 1 left over, so you get
*
*
**
***
or for 9, you have 3 left over:
*
**
***
***
****
or, you can add 1 to various rows to eat the left overs... (your choice where to stick the extras)
*
**
****
for 7^^ or 9:
**
***
****
You still will have a nested loop, but the inner loop will be a for loop, and the outer loop can just be a while (true) loop.
The inner for loop goes from [0, row) (row initially set to 1). Each outer loop, you increment row, and print a newline.
Also keep a "total_stars_printed" variable that you increment each time you print a star, inside each inner for loop. Also inside each inner for loop iteration, check if total_stars_printed == n. If it does, return 0; from main.
You could also do it mathematically like jonnin is saying, but a while loop works too.