ProgrammingVery hardTCS 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> #define SQ(x) x * x #define MAX(a, b) ((a) > (b) ? (a) : (b)) int main(void) { int a = 4, b = 2; printf("%d %d", SQ(a + b), MAX(a, b) * 2); return 0; }

  1. A. 20 8
  2. B. 14 12
  3. C. 36 8
  4. D. 14 8

Correct answer: D. 14 8

SQ(a+b) expands textually to a + b * a + b = 14, not (a+b)². MAX is fully parenthesised so MAX(a,b)*2 = 8.

More C Programming questions

Exams that ask this topic