← The C Language Lesson 17 of 77 · 5 XP

Warm-up: from 1 to n warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

for is handy when you know how many times to repeat. The brackets hold three parts: start, condition and step:

for (int i = 1; i <= 3; i++) {
    printf("%d\n", i);     // 1, 2, 3
}

i++ is the same as i = i + 1.

Task. Read n and print the numbers from 1 to n, each on its own line.

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