Machine-translated by Google. Questions are authored in English.
Top

Discussion

Expression x % y is equivalent to____?

  • A.(x - (x/y))
  • B.(x - (x/y) * y)
  • C.(y - (x/y))
  • D.(y - (x/y) * y)

Answer: B

Correct answer: (x – (x/y) * y)

The standard guarantees that integer division and remainder satisfy

\[ (x / y) \times y + (x \% y) = x \]

Rearranging gives \(x \% y = x - (x / y) \times y\). The multiplication by \(y\) is essential - it is what converts the quotient back into the part of \(x\) that divides exactly.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.