How do you use % to determine if a number is even. I don't understand.
How do you use % to determine if a number is even. I don't understand.
>How do you use % to determine if a number is even. I don't understand.
Divide the value by two, if the remainder is 0 then the value was evenly divided by two and is thus an even number. The % operator saves you from performing several operations in that it simply returns the remainder.Code:if ( val % 2 == 0 ) // Even
-Prelude
My best code is written with the delete key.