C++20 sections · 1024 units
Open in Course

Comparison Operators Overview

Testing conditions

Comparison operators test relationships between values and return bool: either true or false. You use these in if statements, loops, and any logic that makes decisions. C++ provides six comparison operators: equal ==, not equal !=, less than <, greater than >, less or equal <=, and greater or equal >=.

Comparisons produce bool results. bool result = (5 > 3); stores true. Printing this with cout displays 1 for true and 0 for false.