250+ TOP MCQs on C-Preprocessor and Answers

C questions and puzzles on “C Preprocessor”. One shall practice these questions and puzzles to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These programming puzzles can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our C questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C questions and puzzles on “C Preprocessor” along with answers, explanations and/or solutions:

1. Property which allows to produce different executable for different platforms in C is called?
a) File inclusion
b) Selective inclusion
c) Conditional compilation
d) Recursive macros
Answer: c
Clarification: Conditional compilation is the preprocessor facility to produce a different executable.

2. What is #include ?
a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
Answer: a
Clarification: None.

3. C preprocessors can have compiler specific features.
a) True
b) False
c) Depends on the standard
d) Depends on the platform
Answer: a
Clarification: #pragma is compiler specific feature.

4. What will be the output of the following C code?

  1. #include 
  2. #define foo(m, n) m * n = 10
  3. int main()
  4. {
  5.     printf("in mainn");
  6. }

a) In main
b) Compilation error as lvalue is required for the expression m*n=10
c) Preprocessor error as lvalue is required for the expression m*n=10
d) None of the mentioned
Answer: a
Clarification: Preprocessor just replaces whatever is given compiler then checks for error at the replaced part of the code. Here it is not replaced anywhere.
Output:
$ cc pgm1.c
$ a.out
in main

5. C preprocessor is conceptually the first step during compilation.
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
Answer: a
Clarification: None.

6. Preprocessor feature that supply line numbers and filenames to compiler is called?
a) Selective inclusion
b) macro substitution
c) Concatenation
d) Line control
Answer: d
Clarification: None.

7. #include are _______ files and #include “somefile.h” ________ files.
a) Library, Library
b) Library, user-created header
c) User-created header, library
d) They can include all types of file
Answer: d
Clarification: Both of these statement can be used to select any file.

8. What is a preprocessor?
a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned
Answer: a
Clarification: A preprocessor is a program that processes its input data to produce output that is used as input to another program.

Leave a Reply

Your email address will not be published. Required fields are marked *