C Programming Questions and Answers – C Preprocessor – 2

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “C-Preprocessor – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

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

Answer: d
Explanation: Even though using include directives before main() improves readability, it is not mandatory to write it before main() function. Only requirement is that we should include the header files before calling the library function.

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

Answer: c
Explanation: It is primarily used for running a function upon exiting the program.
advertisement
advertisement

3. What will be the output of the following 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
View Answer

Answer: b
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

4. What is #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
View Answer

Answer: a
Explanation: 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.
advertisement

5. 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
View Answer

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

6. 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
View Answer

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

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.