← C++ from Scratch Lesson 18 of 62 · 5 XP

Warm-up: a row of stars warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

for repeats a block a given number of times. To print three stars on one line:

for (int i = 0; i < 3; i++) {
    std::cout << '*';
}
std::cout << '\n';      // the line break — once, after the loop

Task. Read n and print n stars on one line.

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.