O'Reilly logo

Sams Teach Yourself C++ in 24 Hours, Third Edition by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Relational Operators

Relational operators are used to determine whether two numbers are equal, or if one is greater or less than the other. Every relational expression returns either 1 (true) or 0 (false). The relational operators are presented in Table 4.1.

If the integer variable myAge has the value 39, and the integer variable yourAge has the value 40, you can determine whether they are equal by using the relational “equals” operator:

myAge == yourAge;  // is the value in myAge the same as in yourAge?

This expression evaluates to 0, or false, because the variables are not equal. The expression

 myAge > yourAge; // is myAge greater than yourAge? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required