This set of C Multiple Choice Questions & Answers (MCQs) focuses on “File Inclusion – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. If the file name is enclosed in double quotation marks, then _________
a) The preprocessor treats it as a user-defined file
b) The preprocessor treats it as a system-defined file
c) The preprocessor treats it as a user-defined file & system-defined file
d) None of the mentioned
View Answer
Explanation: None.
2. If the file name is enclosed in angle brackets, then ___________
a) The preprocessor treats it as a user-defined file
b) The preprocessor treats it as a system-defined file
c) The preprocessor treats it as a user-defined file & system-defined file
d) None of the mentioned
View Answer
Explanation: None.
3. What will be the output of the following C code snippet?
#include (stdio.h)
void main()
{
printf("hello");
}
a) hello
b) Nothing
c) Compile time error
d) Depends on compiler
View Answer
Explanation: File to be included must be specified either in “” or <>.
Output:
$ cc pgm1.c
pgm1.c:1: error: #include expects “FILENAME” or
pgm1.c: In function ‘main’:
pgm1.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
4. The below two lines are equivalent to ________
#define C_IO_HEADER <stdio.h>
#include C_IO_HEADER
a) #include<stdlib.h>
b) #include”printf”
c) #include”C_IO_HEADER”
d) #include<stdio.h>
View Answer
Explanation: Since C_IO_HEADER is defined to be <stdio.h>, the second line becomes #include<stdio.h>, since C_IO_HEADER is replaced with <stdio.h>
5. What will be the output of the following C code?
#include <stdio.h>
#include "printf"
void main()
{
printf("hello");
}
a) hello
b) Error
c) Depends on compiler
d) Varies
View Answer
Explanation: None.
6. Which of the following file extensions are accepted with #include?
a) .h
b) .in
c) .com
d) All of the mentioned
View Answer
Explanation: The preprocessor will include whatever file extension you specify in your #include statement. However, it is not a good practice as another person debugging it will find it difficult in finding files you have included.
7. Which of the following names for files not accepted?
a) header.h.h
b) 123header.h
c) _head_er.h
d) None of the mentioned
View Answer
Explanation: All file names are accepted as for the execution to occur. There are no constraints on giving file names for inclusion.
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.
- Practice BCA MCQs
- Apply for Computer Science Internship
- Watch Advanced C Programming Videos
- Check C Books
- Check Computer Science Books