ProgrammingHardTCS NQT · C

What is printed?

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

Correct answer: B. 2 0 1

a++ yields 0 so && skips b++; then ++a makes a = 2 (true), so the || skips b++ and c = 1.

More C Programming questions

Exams that ask this topic