ProgrammingHardTCS NQT · Infosys · Product Company SDE

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits)? #include <stdio.h> int main(void) { int x = 12; int y = x++ + 10; int z = ++x * 2; printf("%d %d %d", x, y, z); return 0; }

  1. A. 13 22 26
  2. B. 14 23 28
  3. C. 14 22 28
  4. D. 14 23 30

Correct answer: C. 14 22 28

x++ yields 12 then x=13: y=22. ++x makes x=14, z=14×2=28. Final x = 14.

More C Programming questions

Exams that ask this topic