#87 – Relational Operators

The relational operators (<, >, <=, >=) are used to compare the values of two operands and return a boolean value based on comparing the values of the operands.

  • <       Returns true if the 1st operand is less than the 2nd
  • <=    Returns true if the 1st operand is less than or equal to the 2nd
  • >       Returns true if the 1st operand is greater than the 2nd
  • >=    Returns true if the 1st operand is greater than or equal to the 2nd

The relational operators are typically used on numeric operands (e.g. float, int).  You can also compare objects of type char and enum type members.  More generally, the operators will be available for objects of any type that implements the relational operators.

Advertisements