Which operator is used for ‘logical AND’ in C?
a) &
b) &&
c) ||
d) |
Answer:
b) &&
Explanation:
The logical AND operator (&&
) in C is used to combine two conditions, returning true
only if both conditions are true. For example, the expression x > 0 && x < 10
is true only if x
is greater than 0 and less than 10. This operator is widely used in conditional statements to control the flow of a program based on multiple conditions.
Understanding logical operators like &&
is crucial for implementing complex logical conditions in C programs.