Even or Odd
Completed
Read an integer and print even or odd.
Input
One integer.
Output
One word.
Example
Input
4
Output
even
Editor
C
Hints
Compare n % 2 with 0 - negative odd numbers give -1, not 1.
Solution explanation
In C, any non-zero value counts as true; == gives 1 or 0.
Show solution
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
if (n % 2 == 0) {
printf("even\n");
} else {
printf("odd\n");
}
return 0;
}