C Questions and Answers Part-28

1. #include statement must be written __________
a) Before main()
b) Before any scanf/printf
c) After main()
d) It can be written anywhere

Answer: d

2. #pragma exit is primarily used for?
a) Checking memory leaks after exiting the program
b) Informing Operating System that program has terminated
c) Running a function at exiting the program
d) No such preprocessor exist

Answer: c

3. What will be the output of the following C code?
#include < stdio.h >
int main()
{
int one = 1, two = 2;
#ifdef next
one = 2;
two = 1;
#endif
printf("%d, %d", one, two);
}
a) 1, 1
b) 1, 2
c) 2, 1
d) 2, 2

Answer: b

4. The C-preprocessors are specified with _________symbol.
a) #
b) $
c) ” ”
d) &

Answer: a

5. What is #include directive?
a) Tells the preprocessor to grab the text of a file and place it directly into the current file
b) Statements are not typically placed at the top of a program
c) All of the mentioned
d) None of the mentioned

Answer: a

6. The preprocessor provides the ability for _______________
a) The inclusion of header files
b) The inclusion of macro expansions
c) Conditional compilation and line control
d) All of the mentioned

Answer: d

7. If #include is used with file name in angular brackets.
a) The file is searched for in the standard compiler include paths
b) The search path is expanded to include the current source directory
c) The search path will expand
d) None of the mentioned

Answer: a

8. What is the sequence for preprocessor to look for the file within <>?
a) The predefined location then the current directory
b) The current directory then the predefined location
c) The predefined location only
d) The current directory location

Answer: a

9. Which directory the compiler first looks for the file when using #include?
a) Current directory where program is saved
b) C:COMPILERINCLUDE
c) S:SOURCEHEADERS
d) Both C:COMPILERINCLUDE and S:SOURCEHEADERS simultaneously

Answer: b

10. What would happen if you create a file stdio.h and use #include “stdio.h”?
a) The predefined library file will be selected
b) The user-defined library file will be selected
c) Both the files will be included
d) The compiler won’t accept the program

Answer: b