This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Relational & Logical Operators – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. Are logical operator sequence points?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
2. Do logical operators in the C language are evaluated with the short circuit?
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
3. What is the result of logical or relational expression in C?
a) True or False
b) 0 or 1
c) 0 if an expression is false and any positive number if an expression is true
d) None of the mentioned
View Answer
Explanation: None.
4. What will be the final value of d in the following C code?
#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 5;
int d;
d = b + c == a;
printf("%d", d);
}
a) Syntax error
b) 1
c) 5
d) 10
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 10, b = 5, c = 3;
b != !a;
c = !!a;
printf("%d\t%d", b, c);
}
a) 5 1
b) 0 3
c) 5 3
d) 1 1
View Answer
Explanation: None.
6. Which among the following is NOT a logical or relational operator?
a) !=
b) ==
c) ||
d) =
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int a = 10;
if (a == a--)
printf("TRUE 1\t");
a = 10;
if (a == --a)
printf("TRUE 2\t");
}
a) TRUE 1
b) TRUE 2
c) TRUE 1 TRUE 2
d) Compiler Dependent
View Answer
Explanation: This is a sequence point problem and hence the result will be implementation dependent.
8. Relational operators cannot be used on ____________
a) structure
b) long
c) strings
d) float
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.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for C Internship
- Apply for Computer Science Internship
- Practice Computer Science MCQs
- Practice BCA MCQs
- Watch Advanced C Programming Videos