Which of the following statement(s) is/are true about pre-processor in C/C++?…
2021
Which of the following statement(s) is/are true about pre-processor in C/C++? I. To replace each #include directive with the contents of the designated file. II. To replace each escape sequence with designated character. III. To process macro definitions and expand macro calls.
- A.
I and II
- B.
I and III
- C.
Only I
- D.
I, II and III
Attempted by 187 students.
Show answer & explanation
Correct answer: B
Concept:
The C/C++ build pipeline runs distinct translation phases: the preprocessor performs purely textual, directive-level substitution — expanding #include and #define — before the compiler ever runs. Interpreting the meaning of tokens already in the source, such as converting an escape sequence into its character value, belongs to the compiler's lexical-analysis phase, not the preprocessor.
Application:
Statement I —
#includeis replaced with the contents of the designated file: this is exactly the preprocessor's textual substitution job — True.Statement II — an escape sequence is replaced with its designated character: this interpretation happens when the compiler's lexical analyzer scans characters into tokens, after preprocessing is already complete — False.
Statement III — macro definitions are processed and macro calls expanded:
#definesubstitution is the preprocessor's other core job, alongside#include— True.
Cross-check:
Both surviving statements (I and III) are directive-level textual substitutions carried out before compilation, while II is deferred to a later phase — so exactly two statements hold, matching the option that lists only I and III.
Final Answer:
I and III