C MCQ set number 00678

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?

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

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 , the second line becomes #include, since C_IO_HEADER is replaced with

5. What is the output of this C code?

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

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.

ed010d383e1f191bdb025d5985cc03fc?s=120&d=mm&r=g

DistPub Team

Distance Publisher (DistPub.com) provide project writing help from year 2007 and provide writing and editing help to hundreds student every year.