Difficulty: Easy
Correct Answer: 2,3,4,
Explanation:
Introduction / Context:
The task emphasizes exact output formatting. The macro prints an integer followed by a comma with no trailing space. When invoked three times, the outputs concatenate exactly as they are emitted, producing a compact string with commas but no spaces.
Given Data / Assumptions:
#define PRINT(i) printf("%d,", i)
x=2
, y=3
, z=4
.
Concept / Approach:
Each call writes the decimal value and a comma. Since the format string does not include a space (e.g., "%d, "
), the characters appear back-to-back: 2, then comma, then 3, comma, then 4, comma. There is no newline unless added explicitly elsewhere.
Step-by-Step Solution:
2,
.Second call: prints 3,
immediately after.Third call: prints 4,
immediately after.Final console line: 2,3,4,
.
Verification / Alternative check:
Change the macro to "%d, "
and re-run; you will then see spaces: 2, 3, 4,
.
Why Other Options Are Wrong:
Common Pitfalls:
Ignoring whitespace in format strings; assuming the console inserts spaces automatically (it does not).
Final Answer:
2,3,4,.
Discussion & Comments