Skip to main content

Practice ยท 4 of 5

Star triangle (nested loops)

Implement static void program(int n) that PRINTS a left-aligned triangle of * characters: row 1 has one star, row n has n stars, each row followed by a newline. program(3) prints "*\n**\n***\n".

Difficulty: beginner

Back to lesson: Practice: Practice: Loops