Share via


Relational and Equality Operators:  <, <=, >, >=, ==, !=

The binary relational and equality operators compare their first operand to their second operand to test the validity of the specified relationship. The result of a relational expression is 1 if the tested relationship is true and 0 if it is false. The type of the result is int.

Example

In the following example, two integers are tested for inequality:

// Example of the inequality operator
int nNumA=1, nNumB=2;

if (nNumA != nNumB) {  // it's true: the operands are not equal
    AnyFunction();     // therefore, this function is executed
}