Predict the output of following program?
#include <stdio.h> #define MAX 1000 int main()
{ int MAX = 100;
printf ( "%d " , MAX);
return 0;
} |
(A) 1000
(B) 100
(C) Compiler Error
(D) Garbage Value
Answer: (C)
Explanation: After preprocessing stage of compilation, the function main() changes to following
int main() { int 1000 = 100; // COMPILER ERROR: expected unqualified-id before numeric constant printf("%d ", 1000); return 0; }