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 = 10; int y = x++ + 10; int z = ++x * 2; printf("%d %d %d", x, y, z); return 0; }

  1. A. 12 20 24
  2. B. 12 21 24
  3. C. 12 20 26
  4. D. 12 21 26

Correct answer: A. 12 20 24

x++ yields 10 then x=11: y=20. ++x makes x=12, z=12×2=24. Final x = 12.

More C Programming questions

Exams that ask this topic