What does (10%2)
mean?
The modulus operator (%)
computes the remainder after dividing its first operand by its second.
%
is the modulus operator.
So this essentially says - what is the remainder of 10 divided by 2?
10 % 2 == 0
10 % 5 == 0
10 % 7 == 3
10 % 3 == 1
10 modulo 2, or in other words, it gives you the remainder of a division by 2
For example, 10 % 2 is 0, because there is no remainder after you divide by 2.
eg 10 % 3 -> this would divide by 3, which results in 1 remainder (10 = 3*3 + 1)
10%2 is 0, 10 divided by 2, rest is 0. This can also mean that number is even.
In computing, the modulo operation finds the remainder of division of one number by another.
I've recently seen this code:
int a, b;
[...]
if (a/b == double(a)/b) ...
Haha.
(Hint: What he really wanted was if(!a%b))
% is used fr finding the remainder. now % and / are two different operators. where / gives the quotient, % outputs the remainder.
10 % 2 =0
10/2 =5
10%2 means that when you divide 10 by 2 then what is the remainder.The remainder becomes the answer.
10
----------!