#include <stdio.h>
#define a 10
int main()
{
printf("%d ",a);
#define a 50
printf("%d ",a);
return 0;
}
Answer: B
Correct answer: 10 50
The preprocessor works line by line, top to bottom, so the first printf is expanded while a still means 10 and the second after it has been redefined to 50. The output is 10 50. Redefining a macro to a different value without an intervening #undef is not strictly conforming, so a compiler will warn.
Please log in or register to report this question.