+ 1

Please i need logic on how to to tell a user if the inputed number is an even number

logic

23rd Sep 2017, 2:00 AM
daniel emmanuel
3 Respostas
+ 2
if (a%2 == 0)..... It's even. if (a%2 != 0).......it's odd. it's using if statement in c++. Those are the text expressions.
23rd Sep 2017, 2:06 AM
Suriya
Suriya - avatar
+ 1
Like Suriya said. The % operator returns the remainder from division. If the remainder after dividing by 2 is zero, it is divisible by 2.
26th Sep 2017, 8:06 PM
Thomas Kimball