ProgrammingVery hard

In C, what is the result of 7 / -2 and 7 % -2?

  1. A. -4 and -1
  2. B. -2 and 3
  3. C. -3 and 1
  4. D. 4 and 3

Correct answer: C. -3 and 1

Division truncates toward zero, so 7 / -2 = -3. The remainder takes the sign of the dividend, so 7 - (-3)(-2) = 1.

More C Programming questions

Exams that ask this topic