Which of the following statements regarding the #define directive in C is…

2023

Which of the following statements regarding the #define directive in C is incorrect?

  1. A.

    #define can be used to create symbolic constants.

  2. B.

    #define can define function-like macros with parameters.

  3. C.

    Macros created using #define are expanded by the preprocessor before compilation.

  4. D.

    #define can be used to create multi-line macros using the backslash (\) continuation character.

  5. E.

    #define macros provide automatic type checking similar to C functions.

Attempted by 8 students.

Show answer & explanation

Correct answer: E

Concept

The #define directive is a preprocessor instruction. The preprocessor runs before the compiler and performs pure textual token substitution: every occurrence of the macro name is literally replaced by its replacement list. The preprocessor has no knowledge of C types, declarations, or grammar, so a macro is not a function and carries no type information.

Application

The question asks which statement is incorrect. Because macros are plain text substitution, they cannot perform any type checking on their arguments — the compiler only ever sees the already-substituted text. A claim that #define macros provide automatic type checking like real C functions contradicts how the preprocessor works, so that statement is the false one.

Why the others are true

  • #define PI 3.14159 creates a symbolic constant — a valid and common use.

  • #define SQ(x) ((x)*(x)) is a function-like macro taking a parameter — fully supported.

  • Macro expansion happens in the preprocessing phase, strictly before compilation — correct.

  • A trailing \ (backslash) continues a macro onto the next line, so multi-line macros are allowed — correct.

Cross-check

Substitute a macro mentally: #define SQ(x) ((x)*(x)) applied to SQ(1+1) expands to ((1+1)*(1+1)) — pure text, no type inspection of the argument. This confirms macros do no type checking, so the statement claiming automatic type checking is the incorrect one.

Explore the full course: Ibps So It Mains

Loading lesson…