Relational Operator


Relational Operator

A relational operator is used to check the relationship between two operands. For example,

  1. Check if a>b,
  2. Check if a=b,
  3. Check if a

Relational operators return “true” or “false” according to the data, if in example 1 if a is greater than b then it returns “True” for that particular expression. There are 6 relational operators:

Operator Symbol Relational Operation
== Equal to
!= Not equal
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to

Expression’s first value = a

Expression’s second value = b for upcoming examples:

  1. ==

  2. Return “true” if the value of "first value" is equal to the value of "second value" else return “false” for the expression.

  3. !=

  4. Return “true” if the value of "first value" isn’t equal to the value of "second value" else return “false” for the expression.

  5. >

  6. Return “true” if the value of "first value" is greater than the value of "second value" else return “false” for the expression.

  7. <

  8. Return “true” if the value of "first value" is smaller than the value of "second value" else return “false” for the expression.

  9. >=

  10. Return “true” if the value of "first value" is greater than the equals to the value of "second value" else return “false” for the expression.

  11. <=

  12. Return “true” if the value of "first value" is smaller than equals to the value of "second value" else return “false” for the expression.