C Programming Questions and Answers – Relational & Logical Operators – 2

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

Answer: a
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

Answer: a
Explanation: None.
advertisement
advertisement

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

Answer: b
Explanation: None.

4. What will be the final value of d in the following C code?

Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!
  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10, b = 5, c = 5;
  5.         int d;
  6.         d = b + c == a;
  7.         printf("%d", d);
  8.     }

a) Syntax error
b) 1
c) 5
d) 10
View Answer

Answer: b
Explanation: None.
advertisement

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10, b = 5, c = 3;
  5.         b != !a;
  6.         c = !!a;
  7.         printf("%d\t%d", b, c);
  8.     }

a) 5 1
b) 0 3
c) 5 3
d) 1 1
View Answer

Answer: a
Explanation: None.
advertisement

6. Which among the following is NOT a logical or relational operator?
a) !=
b) ==
c) ||
d) =
View Answer

Answer: d
Explanation: None.

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

  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         int a = 10;
  5.         if (a == a--)
  6.             printf("TRUE 1\t");
  7.         a = 10;
  8.         if (a == --a)
  9.             printf("TRUE 2\t");
  10.     }

a) TRUE 1
b) TRUE 2
c) TRUE 1  TRUE 2
d) Compiler Dependent
View Answer

Answer: d
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

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

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.