ProgrammingModerateTCS NQT · Infosys pattern

What is printed?

What is printed?
#define SQUARE(x) x * x
printf("%d", SQUARE(2 + 3));
  1. A. 11
  2. B. 13
  3. C. 25
  4. D. 10

Correct answer: A. 11

A macro substitutes text, so SQUARE(2 + 3) becomes 2 + 3 * 2 + 3 = 2 + 6 + 3 = 11. Writing #define SQUARE(x) ((x) * (x)) would give 25.

More C Programming questions

Exams that ask this topic