Question 8
Back to Exercise
What is the output of the following C program?
#include <stdio.h>
void setup(void) {
#define LIMIT 10
}
int main(void) {
setup();
printf("%d\n", LIMIT);
return 0;
}
- A 10 Correct
- B Compilation error: LIMIT is not in scope
- C 0
- D Garbage
Correct Answer: Option A
The preprocessor runs before the compiler knows about functions or blocks. A macro is defined from its #define line to the end of the file (or an #undef), wherever that line is.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!