CPP Preprocessor Directives MCQ
Cpp MCQ- Home
- Tutorials
- Cpp
- Preprocessor Directives
- Multiple Choice Question
(1) Which of the following preprocessor directive is used to include library files in source program ?
A) #define
B) #ifndef
C) #undef
D) #include
Explanation
#include directive is used to include library/header files in source program. This directive is normally used in every small and large program.
(2) #endif directive is __________ with #if directive.
A) Optional
B) Mandatory
C) Not a Part
D) None
Explanation
#endif directive is always used with #if directive. Which indicate the ending of #if directive.
(3) Define directives are normally written in.
A) Lower Case
B) Upper Case
C) Propper Case
D) None
Explanation
Define directive are used to define Macros/Symbolic Constants and written in upper case.
(4) Which of the following use to temintae compilation process ?
A) #error
B) #if
C) #ifdef
D) #ifndef
Explanation
#error directive is used to terminate compilation process, and can display some error message. It is normally used with #if directive.
(5) Which of the following directive is used to include conditional code in source program
A) #if
B) #ifdef
C) #ifndef
D) All of these
Explanation
#if, #ifdef and #ifndef all preprocessor directives that are used to include conditional code of lines in source code.
(6) #ifdef directive must include ____________ directive at end
A) #end
B) #endifdef
C) #endif
D) none
Explanation
#ifdef is selection directive it must ends with #endif
(7) Preprocessor directives are alway start with.
A) @
B) *
C) #
D) &
Explanation
# symbol is used in the start of prerocessor name.
(8) Which of the following directive is used to define symbolic constant ?
A) #undef
B) #include
C) #def
D) #if
Explanation
#def define directive is used to define symbolic constants.
(9) Which of the following is not type of preprocessor directive?
A) include
B) def
C) undef
D) None
Explanation
All of these are preprocessor directives.
(10) Preprocessor directives are normally written __________ of the source program.
A) Top
B) Bottom
C) In Between
D) None
Explanation
Preprocessor directives/instructions are the special lines of code. That are most commonly used to include library files, so that these are written at the top of source program.