Vidyalelo
C Programming · Q20

Operators and Expressions

Programming · C Programming · question 20

Q20

What is the order of precedence of the logical operators in C?

A.
AND, OR, NOT
B.
NOT, OR, AND
C.
OR, AND, NOT
D.
OR, NOT, AND
Answer

Answer: Option D

Solution

Answer: Option D
Solution:
In C, the order of precedence for logical operators is as follows: OR (||) has the highest precedence, followed by NOT (!), and then AND (&&). This order ensures that expressions are evaluated correctly based on logical conditions.

Option A (AND, OR, NOT) is incorrect because it doesn't follow the correct order of precedence.
Option B (NOT, OR, AND) is also incorrect for the same reason.
Option C (OR, AND, NOT) is incorrect as it doesn't reflect the correct order of precedence for logical operators in C.