December 27, 2013 Matthew Maennche C++, Learn To Code 10547, C++ 2 LANGUAGE: C++ CHALLENGE: Write an expression that evaluates to true if the integer variable x contains an even value , and false if it contains an odd value. SOLUTION: (x % 2 == 0)
Matthew can you break this down. I don’t understand the answer.
Probly too late but may be others, the % operator finds the remainder of division, so if an even number is divided by 2 the remainder will be 0 and if it’s odd it will not.