ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
int i = 0, j = 1, k;
k = i++ && j++ || ++j;
printf("%d %d %d", i, j, k);
  1. A. 1 2 1
  2. B. 0 1 0
  3. C. 1 2 0
  4. D. 1 3 1

Correct answer: A. 1 2 1

&& binds tighter than ||: (i++ && j++) || ++j. i++ yields 0, so && short-circuits and j++ never runs (i becomes 1). The left side is false, so ++j runs: j = 2, true, k = 1.

More C Programming questions

Exams that ask this topic