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.

  1. A.

    I and II

  2. B.

    I and III

  3. C.

    Only I

  4. 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#include is 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: #define substitution is the preprocessor's other core job, alongside #includeTrue.

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

Explore the full course: Up Lt Grade Assistant Teacher 2025