0
How to differentiate between odd and even number ?
pls help
2 Réponses
+ 2
When dividing a number by 2 you get 2 kinds of results. Either you get a whole number, or you get a point number. If the number /2 is a whole number it is even, otherwise it's odd. To check if it is a whole or point number you need to know the remainder. This is done with the % operator.
if (number % 2 == 0) it's even
else it's odd.
I hope this clear it up.
+ 1
thx alex