Question 2
Back to Exercise
What is the value of -7 % 3?
- A 2
- B -1 Correct
- C 1
- D -2
Correct Answer: Option B
Since C99, / truncates toward zero (−7 / 3 = −2), and % is defined so that (a / b) * b + a % b == a: −2 × 3 + (−1) = −7. The remainder takes the sign of the left operand.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!