-1

What does the code (10%2) mean?

johnnyRose
  • 7,310
  • 17
  • 40
  • 61
shujaat
  • 105
  • 2
  • 2
  • 6

5 Answers5

18

% 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
Oded
  • 489,969
  • 99
  • 883
  • 1,009
4

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)

busybear
  • 10,194
  • 1
  • 25
  • 42
Zaki
  • 1,101
  • 9
  • 7
2

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

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
2

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

Jagmag
  • 10,283
  • 1
  • 34
  • 58
1

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

Dejan Marjanović
  • 19,244
  • 7
  • 52
  • 66