1. If the file name is enclosed in double quotation marks
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
Answer
Answer: a [Reason:] None.
2. If the file name is enclosed in angle brackets
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
Answer
Answer: b [Reason:] None.
3. What is the output of this C code?
-
#include (stdio.h)
-
void main()
-
{
-
printf("hello");
-
}
a) hello
b) Nothing
c) Compile time error
d) Depends on compiler
Answer
Answer: c [Reason:] 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
#include C_IO_HEADER
a) #include
b) #include”printf”
c) #include”C_IO_HEADER”
d) #include
Answer
Answer: d [Reason:] Since C_IO_HEADER is defined to be
5. What is the output of this C code?
-
#include <stdio.h>
-
#include "printf"
-
void main()
-
{
-
printf("hello");
-
}
a) hello
b) Error
c) Depends on compiler
d) Varies
Answer
Answer: a [Reason:] None.
6. Which of the following file extensions are accepted with #include?
a) .h
b) .in
c) .com
d) All of the mentioned
Answer
Answer: d [Reason:] 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 difficulty 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
Answer
Answer: d [Reason:] All file names are accepted as for the execution to occur. There are no constraints on giving file names for inclusion.