Skip to main content

Practice · 4 of 5

Nested-loop rectangle

CHALLENGE
Difficulty: beginner+25 XP

Implement String box(int rows, int cols): a rectangle of # with rows lines and cols characters per line, each line ended by \n. box(2, 3) returns "###\n###\n". Build it with two nested loops (the inner prints one line).

Back to lesson: Practice: Loop rep