www.easyCPlusPlus.com

Easy C++

www.easyCPlusPlus.com

relational operator

by John Kopp

Support this site at no cost to you

Definition: Relational operators are used to compare two operands. Expressions containing relational operators evaluate to true or false in C++. In C, they evaluate to either 0 or 1.

Summary of Relational Operators

Operator Description Example Evaluation
== equal 5 == 4 FALSE
5 == 5 TRUE
!= not equal 5 != 4 TRUE
5 != 5 FALSE
> greater than 5 > 4 TRUE
5 > 5 FALSE
>= greater than or equal 5 >= 4 TRUE
5 >= 5 TRUE
< less than 5 < 4 FALSE
5 < 5 FALSE
<= less than or equal 5 <= 4 FALSE
5 <= 5 TRUE

Related Terms:
• else
• if
• logical operators
• switch

Please use the back button on your browser to return to the last page

           Full Glossary