Question

What does the code (10%2) mean?

Was it helpful?

Solution

% 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

OTHER TIPS

10 modulo 2, or in other words, the remainder of 10 divided by 2.

10 % 2 is 0 because there is no remainder after you divide by 2.

10 % 3 -> this would divide by 3, which results in a remainder of 1 (10 = 3*3 + 1)

The modulus operator (%) computes the remainder after dividing its first operand by its second.

10 % 2 should give you 0. It is the MODULUS operator

10%2 is 0, 10 divided by 2, rest is 0. This can also mean that number is even.

% is basiacally a modulus opertor which gives you the remainder of a division operation between integers.

Here is a exhaustive list of operators in C, their names and functionlaity along with some examples and clear explanation.

% 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

----------!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top