What does the line #define MAX 100 do in a C program?
Correct answer
C. Performs textual substitution before compilation
14 views
C. Performs textual substitution before compilation
14 views
The preprocessor replaces every later occurrence of MAX with the token 100 before the compiler parses the file, so no variable or function is created. Because it is pure text replacement, macros ignore scope and types, which is why #define SQUARE(x) ((x)*(x)) needs the extra parentheses. A const int or an enum is the type-safe modern alternative.
Asked in: NTS, PPSC IT, Campus Interviews
Not sure why the answer is C? Ask here and get an explanation.