ProgrammingModerateProduct-company MCQ pattern

What is printed by a C99 (or later) compiler?

What is printed by a C99 (or later) compiler?
printf("%d %d", -7 / 2, -7 % 2);
  1. A. -4 -1
  2. B. -4 1
  3. C. -3 -1
  4. D. -3 1

Correct answer: C. -3 -1

Since C99 integer division truncates toward zero, so -7 / 2 = -3. The remainder satisfies (a / b) × b + a % b = a, so -7 % 2 = -7 - (-6) = -1; its sign follows the dividend. -4 and 1 are Python's floor-division results.

More C Programming questions

Exams that ask this topic