ProgrammingVery hardProduct company OA

What is printed?

What is printed?
int a = 0, b = 1, c = 2;
if (a++ || b-- && ++c)
    c += 10;
printf("%d %d %d", a, b, c);
  1. A. 1 0 3
  2. B. 1 0 13
  3. C. 1 1 2
  4. D. 1 0 12

Correct answer: B. 1 0 13

&& binds tighter, so it is a++ || (b-- && ++c). a++ yields 0, so the right side runs: b-- yields 1 (b becomes 0) and ++c makes c 3, so the condition is true and c becomes 13. '12' skips the ++c; '1 1 2' wrongly short-circuits after a++.

More C Programming questions

Exams that ask this topic