Difficulty: Easy
Correct Answer: int=2, int=3, int=4,
Explanation:
Introduction / Context:
This question tests your understanding of C preprocessor macros, argument substitution, and how string literals in printf determine the printed text. The parameter name of a macro can shadow language keywords without affecting compilation because the preprocessor runs before the compiler’s parsing stage. The key is to follow the expansion faithfully and read the literal being printed.
Given Data / Assumptions:
#define PRINT(int) printf("int=%d, ", int);x = 2, y = 3, z = 4.printf invocation.
Concept / Approach:
The preprocessor replaces the macro parameter token int with the actual argument, but the literal text "int=%d, " remains unchanged. Thus, PRINT(x) becomes printf("int=%d, ", x);, which prints int=2, . The same happens for y and z. Using int as a macro parameter name is allowed; it does not conflict with the keyword in this context.
Step-by-Step Solution:
PRINT(x) → printf("int=%d, ", x); → prints int=2, .Expand PRINT(y) → prints int=3, .Expand PRINT(z) → prints int=4, .
Verification / Alternative check:
Replace the literal with "val=%d, " to see the difference; or expand the macro with gcc -E (preprocessing only) to confirm the textual substitution.
Why Other Options Are Wrong:
int.
Common Pitfalls:
Thinking the word int in the literal will change with the argument; confusing macro parameter names with C keywords during compilation.
Final Answer:
int=2, int=3, int=4,.
Discussion & Comments