This set of C Multiple Choice Questions & Answers (MCQs) focuses on “File Inclusion – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. 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
View Answer
Explanation: <> first searches the predefined location for the specified file and then the current directory.
2. 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
View Answer
Explanation: None.
3. 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
View Answer
Explanation: None.
4. How is search done in #include and #include “somelibrary.h” according to C standard?
a) When former is used, current directory is searched and when latter is used, standard directory is searched
b) When former is used, standard directory is searched and when latter is used, current directory is searched
c) When former is used, search is done in implementation defined manner and when latter is used, current directory is searched
d) For both, search for ‘somelibrary’ is done in implementation-defined places
View Answer
Explanation: None.
5. How is search done in #include and #include”somelibrary.h” normally or conventionally?
a) When former is used, current directory is searched and when latter is used, standard directory is searched
b) When former is used, predefined directory is searched and when latter is used, current directory is searched and then predefined directories are searched
c) When former is used, search is done in implementation defined manner and latter is used to search current directory
d) For both, search for somelibrary is done in implementation-defined manner
View Answer
Explanation: None.
6. Can function definition be present in header files?
a) Yes
b) No
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
7. Comment on the output of the following C code.
#include <stdio.h>
#include "test.h"
#include "test.h"
int main()
{
//some code
}
a) True
b) Compile time error
c) False
d) Depends on the compiler
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
#define foo(m, n) m ## n
void myfunc();
int main()
{
myfunc();
}
void myfunc()
{
printf("%d\n", foo(2, 3));
}
a) 23
b) 2 3
c) Compile time error
d) Undefined behaviour
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Computer Science Internship
- Practice BCA MCQs
- Watch Advanced C Programming Videos
- Check Computer Science Books
- Apply for C Internship