ProgrammingModerateWipro · Capgemini pattern

What is printed?

What is printed?
int a = 5, b;
b = a++ + 10;
printf("%d %d", a, b);
  1. A. 5 15
  2. B. 5 16
  3. C. 6 16
  4. D. 6 15

Correct answer: D. 6 15

a++ gives the old value 5 to the expression and then increments a, so b = 5 + 10 = 15 and a = 6. 16 would need the pre-increment ++a.

More C Programming questions

Exams that ask this topic