C Preprocessor-1
1. What are the types of C Preprocessor Directives?
a) Macros
b) Conditional Compilation
c) File Inclusion
d) All the above
Answer: D
No explaination is given for this question.
2. Processor Directive in C language starts with?
a) $ symbol (DOLLAR)
b) @ symbol (At The Rate)
c) & symbol (Ampersand)
d) # symbol (HASH)
Answer: D
No explaination is given for this question.
3. Preprocessor in C language works on?
a) DOTC file (.c)
b) DOTEXE file (.exe)
c) DOTH file (.h)
d) DOTCP file (.cp)
Answer: A
.C file is also called Source Code file.
4. What is the another name for .C file?
a) Executable code
b) Source Code
c) Distributable Code
d) Macro code
Answer: B
No explaination is given for this question.
5. What is the keyword used to define a C macro?
a) def
b) definition
c) define
d) defy
Answer: C
#define PI 3.1428.
6. What will be the output of the following C code?
#include <stdio.h>
#define max 100
void main() {
#ifdef max
printf("Hello");
}
a) 100
b) hello
c) "hello"
d) error
Answer: D
No explaination is given for this question.
7. __________ is the Preprocessor directive which is used to end the scope of #ifdef.
a) #elif
b) #ifndef
c) #endif
d) #if
Answer: C
The #ifdef preprocessor directive is used to check if a particular identifier is currently defined or not.
8. The preprocessor directive which checks whether a constant expression results in a zero or non-zero value __________
a) #if
b) #ifdef
c) #undef
d) #ifndef
Answer: A
#if checks whether a constant expression results in zero or not. If the expression is a non-zero value, then the statements between #if and #endif will be executed. If the constant expression results in a zero value, the statements between #if and #endif will not be executed.
9. What will be the output of the following program?
#include <stdio.h>
#define max 100
void main() {
#if (max%10)
printf("Alg");
#endif
printf("bly");
}
a) error
b) Alg
c) bly
d) ALgbly
Answer: D
No explaination is given for this question.
10. The preprocessor directive which is used to remove the definition of an identifier which was previously defined with #define?
a) #ifdef
b) #undef
c) #ifndef
d) #def
Answer: B
#undef is used to remove the definition of any identifier which had been previously defined in the code with #define.