C Preprocessor(Computer Science > C Program ) Questions and Answers
Question 1. C preprocessor
Takes care of conditional compilation
Takes care of macros
Takes care of include files
Acts before compilation
All of the above
Explanation:-
Answer: Option E. -> All of the above
Question 2. What will be the output of the program? #include #define int char void main() { int i = 65; printf("sizeof(i)=%d", sizeof(i)); }
sizeof(i)=2
sizeof(i)=1
Compiler Error
None of These
Explanation:-
Answer: Option B. -> sizeof(i)=1
Question 3. A preprocessor command
need not start on a new line
need not start on the first column
has # as the first character
comes before the first executable statement
Explanation:-
Answer: Option C. -> has # as the first character
Question 4. What will be the output of the following program? #include #define square(x) x*x void main() { int i; i = 64/square(4); printf("%d", i); }
4
64
16
None of These
Explanation:-
Answer: Option B. -> 64
Question 5. What will be the output of the program code? #include #define a 10 void main() { #define a 50 printf("%d", a); }
50
10
Compiler Error
None of These
Explanation:-
Answer: Option A. -> 50
Question 6. Choose the correct statement. I. The scope of a macro definition need not be the entire program. II. The scope of a macro definition extends from the point of definition to the end of the file. III. New line is a macro definition delimiter. IV. A macro definition may go beyond a line.
Question 8. In which stage the following code #include gets replaced by the contents of the file stdio.h
During Preprocessing
During Execution
During linking
During Editing
None of these
Explanation:-
Answer: Option A. -> During Preprocessing
Question 9. What will be output if you will compile and execute the following c code? #include #define max 5 void main(){ int i = 0; i = max++; printf("%d", i++); }
5
6
7
0
Compiler Error
Explanation:-
Answer: Option E. -> Compiler Error
Question 10. What will be the output of the following program? #include #define prod(a,b) a*b void main() { int x=3,y=4; printf("%d", prod(x+2,y-1)); }