0
Know if number is odd or even without using the modulus operator?
I have an int a = 17; I want to know if the nunber is odd or even WITHOUT the modulus operator.
2 Respuestas
+ 1
int b =a÷2
if b×2==a
a is even
else a is odd
+ 1
bool isOdd = a & 1;
I have an int a = 17; I want to know if the nunber is odd or even WITHOUT the modulus operator.