ProgrammingHardTCS NQT · Infosys

What does printf("%d", 7 % -3) print?

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

Correct answer: A. 1

The result of % takes the sign of the dividend in C99 and later, and 7 = (-2)(-3) + 1, so the remainder is 1.

More C Programming questions

Exams that ask this topic