Submitted by tushar pramanick on Mon, 03/11/2013 - 00:12

    Q Is the C preprocessor part of the C compiler?

    A No. The C preprocessor is not part of the C compiler. With its own line-oriented grammar and syntax, the C preprocessor runs before the compiler in order to handle named constants, macros, and inclusion of files.

    Q How do you remove a macro name?

    A By putting a macro name after the #undef directive, the macro name can be removed. According to the ANSI C standard, a macro name has to be removed before it can be redefined.

    Q Why do you need the #endif directive?

    A The #endif directive is used with an #if, #ifdef, or #ifndef directive because statements under the control of a conditional preprocessor directive are not enclosed in braces ({ and }). Therefore, #endif must be employed to mark the end of the block of statements.

    Q Can the conditional expression following the #if directive be an arithmetic expression?

    A Yes. The conditional expression evaluated by the #if directive can be an arithmetic expression. If the expression returns a nonzero value, the code between the #if directive and the next nearest directive are included for compilation. Otherwise, the code is skipped.
 

Related Items

The continue Statement

The continue Statement

The break Statement

The break Statement

You can add a break statement at the end of the statement list following every case label, if you want to exit the switch construct after the statements within a selected case are executed.

The switch Statement

The switch Statement

Nested if Statements

Nested if Statements

As you saw in the previous sections, one if statement enables a program to make one decision. In many cases, a program has to make a series of decisions. To enable it to do so, you can use nested if statements.

The if-else Statement

The if-else Statement