Read the question, write C on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read one integer. Print even if it is divisible by 2, otherwise print odd.
Print the word in lowercase, with no extra punctuation.
Input. One integer n.
Output. even or odd
Constraints
- 0 ≤ n ≤ 1 000 000
Examples
Input
4
Output
even
Input
7
Output
odd
Hint
- The remainder operator is %. n % 2 is 0 when n is even.
- Use if / else and printf("even\n") or printf("odd\n").
Show correct code
Peek only after you have tried. You can still Check your own version.
#include <stdio.h>
int main(void) {
int n;
if (scanf("%d", &n) == 1) {
if (n % 2 == 0) {
printf("even\n");
} else {
printf("odd\n");
}
}
return 0;
}
main.cC17 · gcc · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.