ProgrammingHardHCL · Tech Mahindra · C placement

What is the output of this C program (assume a typical 64-bit platform: int 32 bits, long and pointers 64 bits, double 8 bytes, structs aligned to their widest member with no packing pragma)? #include <stdio.h> int main(void) { #define INCR(x) x++ int a = 5; int b = 2 * INCR(a); printf("%d %d", a, b); return 0; }

  1. A. 6 10
  2. B. 6 11
  3. C. 5 10
  4. D. 6 12

Correct answer: A. 6 10

INCR(a) expands to a++, a postfix increment that yields the old value 5; b = 2 * 5 = 10, and a becomes 6 as a side effect.

More C Programming questions

Exams that ask this topic