Use the modulus operator to check the last digit

The modulus operator is useful for checking the last digit of your number.

Checking numbers which ends with five:

if( number % 5 ==0)
   // number ends with five

Or detecting odd or even numbers, like this

if(number %2 == 0)
   // number is even




Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!