Explain relational and logical operators with suitable examples
Answers
Answered by
5
Explanation:
A relational operator is used to check the relationship between two operands. For example,
// checks if a is greater than b a > b;
Here, > is a relational operator. It checks if a is greater than b or not.
If the relation is true, it returns 1 whereas if the relation is false, it returns 0.
The following table summarizes the relational operators used in C++.
OperatorMeaningExample==Is Equal To3 == 5 gives us false!=Not Equal To3 != 5 gives us true>Greater Than3 > 5 gives us false<Less Than3 < 5 gives us true>=Greater Than or Equal To3 >= 5 give us false<=Less Than or Equal To3 <= 5 gives us true
== Operator
The equal to == operator returns
true - if both the operands are equal or the samefalse - if the operands are unequal
For example,
Similar questions