ProgrammingHard

#define SQ(x) ((x) * (x)) printf("%d", SQ(2 + 1)); What is printed?

  1. A. 5
  2. B. 7
  3. C. 6
  4. D. 9

Correct answer: D. 9

The parentheses in the macro body make the argument 2 + 1 expand to (2 + 1) * (2 + 1) = 9.

More C Programming questions

Exams that ask this topic