A relational operator is a
programming language construct or operator that tests or defines some kind of relation between two entities . These include numerical equality (such as 8 = 8) and inequalities (such as 7 ≥
4).
In C++, there are six basic relational operators that are used to compare two values of the same data type. The relational operator returns True (1) or false (0) as a result of comparison between two values. These operators are used to specify conditions in the programs. In the following table, operator symbols, meaning and purpose are described.
Operator | Meaning | Description |
---|---|---|
== | Equal to | This operator returns true if both values equal, otherwise returns false. |
!= | Not equal to | Returns true if both values are different, otherwise returns false. |
> | Greater than | Returns true if first value is greater than second value, otherwise returns false. |
Less than | Returns true if first value is less than second value, otherwise returns false. | |
>= | Greater than or Equal to | Returns true in the both case if first value is equal to or greater than, otherwise returns false. |
Less than or Equal to | Returns true if first value is less than or equal to second value, otherwise returns false. |