A condition or logical expression is an expression that can only take the values true or false. A simple form of logical expression is the relational expression. The following is an example of a relational expression:
which takes the value true if the value of the variable
x < y
xis less than the value of the variable
The general form of a relational expression is:
operand1 relational-operator operand2
The operands can be either variables, constants or expressions. If an operand is an expression then the expression is evaluated and its value used as the operand. The relational-operators allowable in C++ are:
Note that equality is tested for using the operator
<=less than or equal to
>=greater than or equal to
=is already used for assigning values to variables.
The condition is true if the values of the two operands satisfy the relational operator, and false otherwise.