Booleans | SoloLearn: Learn to code for FREE!



Is there a way to use a boolean to check if a number is even or odd?

12/28/2016 11:02:58 PM


3 Answers

New Answer


You can use boolean logic and some math to determine if a number is even or odd. For example some pseudocode, If (X % 2 == 0) Then even else Odd Modulus can be used to determine this since if a number is divisible by 2 with no remainder, it is an even number (4, 6, 120). If not then it is odd.


write a method depending on the language from return type boolean then write a simple if your number % 2 equals 0 then return true else return false


Use an if else statement and the % sign. I'll leave it to you to figure it out. 😃