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 = 5, b = 3; printf("%d %d", SQ(a + b), MAX(a, b) * 2); return 0; }

  1. A. 23 10
  2. B. 34 10
  3. C. 23 7
  4. D. 23 16

Correct answer: A. 23 10

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

More C Programming questions

Exams that ask this topic