ProgrammingHardTCS NQT · Infosys

#define N 3 and int a[N * 2 + 1]; What is sizeof a / sizeof a[0]?

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

Correct answer: B. 7

N * 2 + 1 expands to 3 * 2 + 1 = 7, so the array has seven elements. The macro is plain text, which is why the expression is evaluated after substitution.

More C Programming questions

Exams that ask this topic