+ 1

Please explain (a%2==0)

if the remainder is 2 then why 0

15th Nov 2016, 4:07 AM
vinod nair
vinod nair - avatar
5 Answers
+ 5
a%2==0 a is a variable having any value. % means remainder. 2 is the number from which you are dividing a to get the remainder. == is not assignment operator. It checks if the expression on both side of it are equal or not. So if a=5 Then a%2==1 will result into true. a%2==0 will result into false.
15th Nov 2016, 4:52 AM
Megatron
Megatron - avatar
+ 2
When you take modulus/remainder (%) you can get up to one less than it. So, if you did (a % 5) you could get 0, 1, 2, 3, or 4. If you get 0, then they divide with no (0) remainder.
15th Nov 2016, 4:19 AM
JayDepp
JayDepp - avatar
+ 1
What does a equal?
15th Nov 2016, 4:13 AM
Keto Z
Keto Z - avatar
0
thank you guys
15th Nov 2016, 4:55 AM
vinod nair
vinod nair - avatar
0
a%2==0; This actually helps to know wether remainder of a divided by 2 is zero (where a can be any number).
15th Nov 2016, 11:32 AM
Shazib Khattal