Saturday, February 9, 2019

Relational Operators

Conditional Operators (Relational Operators):

+---------+------------------------+
|    <    | Less than              |
|    >    | Greater than           |
|    <=   | Less than or equal     |
|    >=   | Greater then or equal  |
|    ==   | Equal                  |
|    !=   | Not equal              |
+---------+------------------------+

Relational Operators are used to check if a condition is True or False. A relational expression always returns either True or False. Below are some examples for each operator.

Less than:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     3 < 4      |       True       |
|     7 < 5      |       False      |
|     5 < 5      |       False      |
|    -6 < -2     |       True       |
+----------------+------------------+

Greater than:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     7 > 4      |       True       |
|    17 > 29     |       False      |
|    10 > 10     |       False      |
|    -6 > -9     |       True       |
+----------------+------------------+

Less than or equal:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     5 <= 7     |       True       |
|    17 <= 12    |       False      |
|    10 <= 10    |       True       |
|    -6 <= -9    |       False      |
+----------------+------------------+

Greater then or equal:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     7 >= 4     |       True       |
|    17 >= 29    |       False      |
|    10 >= 10    |       True       |
|    -6 >= -9    |       True       |
+----------------+------------------+

Equal:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     7 == 7     |       True       |
|    17 == 29    |       False      |
|    -6 == -9    |       False      |
+----------------+------------------+

Not equal:

+----------------+------------------+
|    Examples    |      Result      |
+----------------+------------------+
|     7 != 4     |       True       |
|    17 != 29    |       True       |
|    10 != 10    |       False      |
|    -6 != -9    |       True       |
+----------------+------------------+

.

No comments: