+ 1
Please explain (a%2==0)
if the remainder is 2 then why 0
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.
+ 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.
+ 1
What does a equal?
0
thank you guys
0
a%2==0;
This actually helps to know wether remainder of a divided by 2 is zero (where a can be any number).