+ 3
#include <iostream>
using namespace std;
// other way around, I was wrong
bool odd(const char x)
{
return x%2;
}
int main()
{
char c = 23;
if (odd(c))
cout << "odd";
else
cout << "even";
}
+ 6
if (n%2 == 0)
; //even
else
; //odd n%2 == 1
+ 4
char is a form of int so this works for it too
+ 4
char n = '7';
if (n%2 == 0) // perfectly legal
n = 5;
+ 1
bool even(const char x)
{
return x%2;
}
bool odd(const char x)
{
return !even(x)
}
0
Cool, so it's solved.
- 1
bool even(int x)
{
return x%2;
}
Is this what you need?
- 1
Do you want to check if a char is even or odd?
- 1
Is if-else really required?