ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
#define SQUARE(x) x * x
int main(void) {
    int a = 3;
    printf("%d", SQUARE(a + 1));
}
  1. A. 7
  2. B. 16
  3. C. 9
  4. D. 4

Correct answer: A. 7

Macros are pure text substitution with no implicit parentheses: SQUARE(a+1) expands to a + 1 * a + 1 = 3 + 1*3 + 1 = 3+3+1 = 7 (multiplication binds tighter than the surrounding addition).

More C Programming questions

Exams that ask this topic