ProgrammingHardTCS NQT · Infosys

#define DOUBLE(x) (x + x). What does printf("%d", DOUBLE(2) * 3) print?

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

Correct answer: C. 12

The macro expands to (2 + 2) * 3 = 12. The outer parentheses in the macro body are what make the expansion safe here.

More C Programming questions

Exams that ask this topic