Log In Register

Units


File Inclusion - Questions and Answers

 

Practice these File Inclusion under C Programming walk-in interview Questions/ examination questions with best tricks and short cuts with solution. Student (candidate) who want to crack the walk in interview, competitive exams and want to find short cuts and tricks to solve questions on File Inclusion for following purpose.


– Anyone who is wishing to increase their perfect knowledge of File Inclusion of C Programming.
– Anyone who is preparing for aptitude test and increase his in depth aptitude knowledge C Programming specifically File Inclusion.
– Anyone who is preparing for interviews (competitive examinations, govt examinations and bank examinations, off-campus or on campus interviews, walk-in interview and company interviews) having questions on File Inclusion under C Programming.

– Anyone who is preparing for aptitude test or competitive exam or entrance exam.
– Anyone who is preparing for entrance examinations and other competitive examinations.
– All Experienced, Freshers and Students.

Here is list of Questions and Answers covering all key area of  File Inclusion topic of C Programming:

 

1.

What is the sequence for preprocessor to look for the file within <> ?

Answer: Option D

Explanation:

<> first searches the predefined location for the specified file and then the current directory.
Explanation: None.

2.

Which directory the compiler first looks for the file when using #include ?

Answer: Option C

Explanation:

The order of file look up is in the sequence of option b, c, a.
Explanation: None.

3.

Which of the following file extensions are accepted with #include?

Answer: Option D

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 difficulty in finding files you have included.

4.

What is the output of this C code?

  1.     #include (stdio.h)
  2.     void main()
  3.     {
  4.         printf("hello");
  5.     }

Answer: Option B

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’

5.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #define foo(m, n) m ## n
  3.     void myfunc();
  4.     int main()
  5.     {
  6.         myfunc();
  7.     }
  8.     void myfunc()
  9.     {
  10.         printf("%d\n", foo(2, 3));
  11.     }

Answer: Option D

Explanation:

6.

Can function definition be present in header files?

Answer: Option D

Explanation:

7.

What would happen if you create a file stdio.h and use #include “stdio.h” ?

Answer: Option C

Explanation:

8.

How is search done in #include and #include”somelibrary.h” normally or conventionally?

Answer: Option D

Explanation:

9.

If the file name is enclosed in angle brackets

Answer: Option C

Explanation:

10.

Comment on the output of this C code?

  1.     #include <stdio.h>
  2.     #include "test.h"
  3.     #include "test.h"
  4.     int main()
  5.     {
  6.         //some code
  7.     }

Answer: Option C

Explanation:

11.

How is search done in #include and #include “somelibrary.h” according to C standard?

Answer: Option A

Explanation:

12.

If the file name is enclosed in double quotation marks

Answer: Option C

Explanation:

13.

What is the output of this C code?

  1.     #include <stdio.h>
  2.     #include "printf"
  3.     void main()
  4.     {
  5.         printf("hello");
  6.     }

Answer: Option D

Explanation:

14.

The below two lines are equivalent to
#define C_IO_HEADER
#include C_IO_HEADER

Answer: Option A

Explanation:

Since C_IO_HEADER is defined to be , the second line becomes #include, since C_IO_HEADER is replaced with

15.

Which of the following names for files not accepted?

Answer: Option A

Explanation:

All file names are accepted as for the execution to occur. There are no constraints on giving file names for inclusion.