0

How to differentiate between odd and even number ?

pls help

15th Apr 2018, 3:00 PM
Hakim razak
Hakim razak - avatar
2 Respuestas
+ 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.
15th Apr 2018, 3:17 PM
Alex
Alex - avatar
+ 1
thx alex
15th Apr 2018, 3:33 PM
Hakim razak
Hakim razak - avatar