← The C Language Lesson 13 of 77 · 5 XP

Warm-up: even or odd warm-up

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

The % sign gives the remainder of a division. An even number has remainder 0 when divided by 2:

if (n % 2 == 0) {
    printf("even\n");
} else {
    printf("odd\n");
}

The condition goes in round brackets, and the comparison uses two signs: ==.

Task. Read an integer and print even if it is even, otherwise odd.

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