ProgrammingVery hardTCS NQT · Infosys

#define ADD(a,b) a+b. What does printf("%d", 2 * ADD(1,2) * 3) print?

  1. A. 8
  2. B. 9
  3. C. 18
  4. D. 12

Correct answer: A. 8

The expansion is 2 * 1+2 * 3, which is 2 + 6 = 8. Macro arguments and bodies need parentheses to behave like a function call.

More C Programming questions

Exams that ask this topic