C: Even or odd

Read a whole number n. Print even if it is even and odd if it is odd.

What to build

A program with two possible answers.

Requirements

  • Read a whole number.
  • Print even or odd.

Input

One whole number between -1000000 and 1000000.

Output

even or odd.

Constraints

The number is between -1000000 and 1000000.

Example

Input:

4

Output:

even

Why it works

An even number leaves no remainder when divided by 2, and comparing with 0 also works for negative numbers, where the remainder of an odd number is -1.

Examples

Example 1 · Input
4
Expected output
even
Example 2 · Input
7
Expected output
odd

Hints

Hint 1

n % 2 is 0 for even numbers.

Hint 2

For a negative odd number, n % 2 is -1 in C, so test == 0 rather than == 1.

Solution

Show one correct solution (try it yourself first)
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    if (n % 2 == 0) printf("even\n");
    else printf("odd\n");
    return 0;
}

Lesson: Decisions: if, else and switch →