ProgrammingModerateTCS NQT · Infosys

What does printf("%d %d", 17 / 5, 17 % 5) print?

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

Correct answer: A. 3 2

17 / 5 truncates to 3, and 17 % 5 is 2. Both operators work on int with non-negative operands, so the results are unambiguous.

More C Programming questions

Exams that ask this topic