C | Macro & Preprocessor | Question 12

Predict the output of following program?

filter_none

edit
close

play_arrow

link
brightness_4
code

#include <stdio.h>
#define MAX 1000
int main()
{
   int MAX = 100;
   printf("%d ", MAX);
   return 0;
}

chevron_right


(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;
}


Quiz of this Question



My Personal Notes arrow_drop_up