ProgrammingHardIBM · Deloitte pattern

What is printed?

What is printed?
#define N 5
#undef N
#define N 10
printf("%d", N);
  1. A. 10
  2. B. 5
  3. C. Compilation error: N redefined
  4. D. 15

Correct answer: A. 10

#undef removes the previous definition of N before the second #define installs the new one, so by the time printf expands, N is 10, with no redefinition conflict.

More C Programming questions

Exams that ask this topic