Question 1 :
If the file to be included doesn't exist, the preprocessor flashes an error message.
True, the included file does not exist it will generate the error.
Question 2 :
Preprocessor directive #undef can be used only on a macro that has been #define earlier
True, #undef can be used only on a macro that has been #define earlier
Example: #define PI 3.14
We can undefine PI macro by #undef PI
Question 3 :
There exists a way to prevent the same file from getting #included twice in the same program.
True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef (short for "if not defined") to determine whether we've already defined a preprocessor symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest of the file until it sees a #endif (which in this case is at the end of the file).
#define XSTRING_H defines the same preprocessor symbol,
Finally, the last line of the file, #endif
Question 4 :
A preprocessor directive is a message from programmer to the preprocessor.
True, the programmer tells the compiler to include the preprocessor when compiling.
Question 5 :
Macro calls and function calls work exactly similarly.
False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program.
A function is compiled once and can be called from anywhere that has visibility to the funciton.
Question 6 :
A macro must always be defined in capital letters.
FALSE, The macro is case insensitive.
Question 7 :
Macros have a local scope.
False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.
Question 8 :
Every C program will contain at least one preprocessor directive.
False, the preprocessor directive is not mandatory in any c program.
Question 9 :
Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation.
True, these macros are used for conditional operation.
Question 10 :
Macros with arguments are allowed
True, A macro may have arguments.
Example: #define CUBE(X)(X*X*X)
Question 11 :
In a macro call the control is passed to the macro.
False, Always the macro is substituted by the given text/expression.
Question 12 :
A header file contains macros, structure declaration and function prototypes.
True, the header file contains classes, function prototypes, structure declaration, macros.
Question 13 :
The preprocessor can trap simple errors like missing declarations, nested comments or mismatch of braces.
False, the preprocessor cannot trap the errors, it only replaces the macro with the given expression. But the compiler will detect errors.
Question 14 :
A preprocessor directive is a message from compiler to a linker.
Example: #define symbol replacement
When the preprocessor encounters #define directive, it replaces any occurrence of symbol in the rest of the code by replacement. This replacement can be an statement or expression or a block or simple text.
Question 15 :
Once preprocessing is over and the program is sent for the compilation the macros are removed from the expanded source code.
True, After preprocessing all the macro in the program are removed.