LearnFrenzy
Sign in Take a free test

Operators and Expressions · Operators MCQ · Question 2

What is -7 % 3 in C? Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links