Relational Operator
The operators that are used to specify a relation between two expressions or values are known as relational operators.
> | Greater Than e1>e2 It is used to test if one expression is greater than the other expression. |
>= | Greater Than or Equal To e1>=e2 It is used to test if one expression is greater than or equal to the other expression. |
< | Less Than It is used to test if one expression is less than the other expression. e1<e2 |
<= | Less Than Or Equal To It is used to test if one expression is less than or equal to the other expression. e1<=e2 |
== | Equal To if e1 and e2 are two expressions then: e1==e2 if e1 is equal to e2 then expression returns TRUE value |
!= | Not Equal TO it is used to test if one expression is not equal to the other expression: e1!=e2 |
Example:
If x=10, y=20, and z=5 then find out the output of the following relational expressions.
Relational Expression | OutPut Returned |
---|---|
x>y | False |
False | |
y!=x | True |
x==z | False |
x<=y | True |
z>=y | False |