-4

Let's say x=29 and y=13. What does this line of code actually do:

x%=y-3;

I just don't really know what does this mean?

alk
  • 69,737
  • 10
  • 105
  • 255
Ice
  • 3
  • 4

1 Answers1

1

Modulo operator gives you remainder from division.

a % b is the remainder of division a by b

x %= y - 3 is equal to x = x % (y - 3) and gives you remainder from division x by (y - 3) expression.

  • OP should do their homework but as you already posted an answer it would be good IMO to describe the difference between modulus and the remainder when negative arguments are used. For example, `10 % -3` would give 1 in C but would give -2 in Python. – Arkadiusz Drabczyk Nov 02 '19 at 19:53