The Equality and Relational Operators


Sometimes known colloquially as "comparison" operators.

Meaning Operator

C
Pascal
Ada
FORTRAN
equal to == = = .EQ.
not equal != <> /= .NE.
less than < < < .LT.
less than or equal to <= <= <= .LE.
greater than > > > .GT.
greater than or equal to >= >= >= .GE.


The Logical or "Boolean" Operators


Meaning Operator

C
Pascal
Ada
FORTRAN
and && AND AND .AND.
or || OR OR .OR.
not ! NOT NOT .NOT.


Conditions or Logical Expressions in C


Variables
Condition Value
count = 2
kMaxPeople = 99
count < kMaxPeople
true
sum = 10
limit = 99
sum >= limit false
m = 5  m > 0 && m < 100
true
m = 5 m == 10 false
m = 5
(or any nonzero value)
m = 10 true

Note that C does not have a built-in boolean data type.
Instead, C uses the integer 0 for false and 1 (actually, any nonzero value) for true.