ProgrammingModerateTCS NQT · Infosys

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

  1. A. 11
  2. B. 25
  3. C. 12
  4. D. 9

Correct answer: A. 11

Macros substitute text, so the expansion is 2+3*2+3. Multiplication runs first: 2 + 6 + 3 = 11. A correct macro writes ((x)*(x)).

More C Programming questions

Exams that ask this topic