250+ TOP MCQs on Conditional Inclusion and Answers

C Objective Questions on “Conditional Inclusion”. One shall practice these Objective Questions to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions 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 Objective Questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C Objective Questions on “Conditional Inclusion” along with answers, explanations and/or solutions:

1. For each #if, #ifdef, and #ifndef directive.
a) There are zero or more #elif directives
b) Zero or one #else directive
c) One matching #endif directive
d) All of the mentioned
Answer: d
Clarification: None.

2. The #else directive is used for _________
a) Conditionally include source text if the previous #if, #ifdef, #ifndef, or #elif test fails
b) Conditionally include source text if a macro name is not defined
c) Conditionally include source text if a macro name is defined
d) Ending conditional text
Answer: a
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0
  3.     #if MIN
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN);
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error
c) Undefined behaviour
d) None of the mentioned
Answer: b
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0
  3.     #ifdef MIN
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN);
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error
c) Undefined behaviour
d) None of the mentioned
Answer: a
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0
  3.     #if defined(MIN) + defined(MAX)
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN);
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error
c) Undefined behaviour
d) Somegarbagevalue 0
Answer: a
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0
  3.     #if defined(MIN) - (!defined(MAX))
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN);
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error
c) Undefined behaviour
d) Somegarbagevalue 0
Answer: b
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0
  3.     #ifdef(MIN)
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN);
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error
c) Run time error
d) Preprocessor error
Answer: d
Clarification: None.

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

  1.     #include 
  2.     #define MIN 0);
  3.     #ifdef MIN
  4.     #define MAX 10
  5.     #endif
  6.     int main()
  7.     {
  8.         printf("%d %dn", MAX, MIN
  9.         return 0;
  10.     }

a) 10 0
b) Compile time error due to illegal syntax for printf
c) Undefined behaviour
d) Compile time error due to illegal MIN value
Answer: a
Clarification: None.

Leave a Reply

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