411 REFERENCE · Wikibooks
Programming Fundamentals/Relational Operators
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Overview
A relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities. These include numerical equality (e.g., 5 = 5) and inequalities (e.g., 4 ≥ 3).Wikipedia: Relational operator
Discussion
Relational operators give a Boolean value (data type that has one of two possible values to represent the two truths of logic) by evaluating the relationship between two operands.
Operator symbols and/or names can vary with different programming languages. Most programming languages use relational operators similar to the following:
OperatorMeaning<less than>greater than<=less than or equal to>=greater than or equal to==equality (equal to)!= or <>inequality (not equal to)
Examples:
9 < 25
9 < 3
9 > 14
9 <= 17
9 >= 25
9 == 13
9 != 13
9 !< 25
9 <> 25
Note: Be careful. In math you are familiar with using the symbol = to mean equal and ≠ to mean not equal, but in many programming languages the ≠ is not used and the = symbol means assignment.
Key Terms
relational operator
An operator that gives a Boolean value by evaluating the relationship between two operands.
References
cnx.org: Programming Fundamentals – A Modular Structured Approach using C++