ProgrammingModerateTCS NQT · Wipro

What is printed?

What is printed?
#include <stdio.h>
int main(void) {
    printf("%d", 10 / 3 * 3 + 10 % 3);
}
  1. A. 9
  2. B. 10
  3. C. 2
  4. D. 1

Correct answer: B. 10

For positive ints (a / b) * b + a % b always equals a, so 3 * 3 + 1 = 10. 9 drops the % term, 2 groups the first part as 10 / (3 * 3), and 1 applies % 3 to the whole sum.

More C Programming questions

Exams that ask this topic