C MCQ set number 00718

1. Which of the following are C preprocessors?
a) #ifdef
b) #define
c) #endif
d) all of the mentioned

Answer

Answer: d [Reason:] None.

2. #include statement must be written
a) Before main()
b) Before any scanf/printf
c) After main()
d) It can be written anywhere

Answer

Answer: b [Reason:] Using these directives before main() improves readability.

3. #pragma exit is primarily used for?
a) Checking memory leaks after exitting the program
b) Informing Operating System that program has terminated
c) Running a function at exitting the program
d) No such preprocessor exist

Answer

Answer: c [Reason:] It is primarily used for running a function upon exitting the program.

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int one = 1, two = 2;
  5.         #ifdef next
  6.         one = 2;
  7.         two = 1;
  8.         #endif
  9.         printf("%d, %d", one, two);
  10.     }

a) 1, 1
b) 1, 2
c) 2, 1
d) 2, 2

Answer

Answer: b [Reason:] None.

5. The C-preprocessors are specified with _________symbol.
a) #
b) $
c) ” ”
d) None of the mentioned

Answer

Answer: a [Reason:] The C-preprocessors are specified with # symbol.

6. The #include directive
a) Tells the preprocessor to grab the text of a file and place it directly into the current file
b) Statements are not typically placed at the top of a program
c) All of the mentioned
d) None of the mentioned

Answer

Answer: a [Reason:] The #include directive tells the preprocessor to grab the text of a file and place it directly into the current file and are statements are typically placed at the top of a program.

7. The preprocessor provides the ability for _______________
a) The inclusion of header files
b) The inclusion of macro expansions
c) Conditional compilation and line control.
d) All of the mentioned

Answer

Answer: d [Reason:] The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.

8. If #include is used with file name in angular brackets
a) The file is searched for in the standard compiler include paths
b) The search path is expanded to include the current source directory
c) The search path will expand
d) None of the mentioned

Answer

Answer: a [Reason:] With the #include, if the filename is enclosed within angle brackets, the file is searched for in the standard compiler include paths.

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.