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
n % 2 is -1 for negative odd numbers, so compare with 0.
Solution explanation
The condition goes in parentheses; the branches in braces.
Show solution
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
if (n % 2 == 0) {
cout << "even\n";
} else {
cout << "odd\n";
}
return 0;
}