← Back to Loops
Question 275
Star Triangle
Star Triangle
Print a left-aligned triangle made of asterisks: 1 star on the first row, 2 on the second, and so on up to 5 stars on the fifth row. This needs a loop inside a loop. The outer loop handles each row number, and the inner loop prints the correct number of stars for that row usingConsole.Write(which does not add a line break). After the inner loop, callConsole.WriteLine()with no text to move to the next row.
Expected Output:
* ** *** **** *****
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Loops
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.