ProgrammingHardTCS NQT · Infosys pattern

What is printed?

What is printed?
#define IS_EVEN(n) ((n) % 2 == 0)
int a = 7;
printf("%d", IS_EVEN(a + 1));
  1. A. 1
  2. B. 0
  3. C. 8
  4. D. Compilation error

Correct answer: A. 1

Because the macro body fully parenthesizes its parameter, IS_EVEN(a+1) safely expands to ((a + 1) % 2 == 0) = (8 % 2 == 0) = (0 == 0) = 1 (true), with no precedence surprises since (a+1) stays grouped.

More C Programming questions

Exams that ask this topic