This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Conditional Inclusion – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
#define SYSTEM 20
int main()
{
int a = 20;
#if SYSTEM == a
printf("HELLO ");
#endif
#if SYSTEM == 20
printf("WORLD\n");
#endif
}
a) HELLO
b) WORLD
c) HELLO WORLD
d) No Output
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
#define Cprog
int main()
{
int a = 2;
#ifdef Cprog
a = 1;
printf("%d", Cprog);
}
a) No output on execution
b) Output as 1
c) Output as 2
d) Compile time error
View Answer
Explanation: None.
3. The “else if” in conditional inclusion is written by?
a) #else if
b) #elseif
c) #elsif
d) #elif
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
#define COLD
int main()
{
#ifdef COLD
printf("COLD\t");
#undef COLD
#endif
#ifdef COLD
printf("HOT\t");
#endif
}
a) HOT
b) COLD
c) COLD HOT
d) No Output
View Answer
Explanation: None.
5. Which of the following sequences are unaccepted in C language?
a)
#if #else #endif
b)
#if #elif #endif
c)
#if #if #endif
d)
#if #undef #endif
Explanation: None.
6. In a conditional inclusion, if the condition that comes after the if is true, then what will happen during compilation?
a) Then the code up to the following #else or #elif or #endif is compiled
b) Then the code up to the following #endif is compiled even if #else or #elif is present
c) Then the code up to the following #eliif is compiled
d) None of the mentioned
View Answer
Explanation: None.
7. Conditional inclusion can be used for ___________
a) Preventing multiple declarations of a variable
b) Check for existence of a variable and doing something if it exists
c) Preventing multiple declarations of same function
d) All of the mentioned
View Answer
Explanation: None.
8. The #elif directive cannot appear after the preprocessor #else directive.
a) True
b) False
View Answer
Explanation: None.
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.
- Watch Advanced C Programming Videos
- Practice Computer Science MCQs
- Check Computer Science Books
- Apply for Computer Science Internship
- Apply for C Internship