O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

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

Comparison And Logical Operators

Using a simple variable (as in the previous example) as a condition won't take you very far in your programming. In order to make more complex, real-world if statements, you'll want to utilize the various comparison and logical operators (Table 4.1).

Table 4.1. These comparison and logical operators are frequently used in conditionals and other control structures.
Comparison and Logical Operators
OperatorMeaning
>Greater than
<Less than
>=Greater than or equal to
>=Less than or equal to
==Equal to
!=Not equal to
&&and
||or
!not

The comparison operators are used with mathematical values, for example, to tell if one value is greater than, equal to, or less than another. Using these, the true/false status of a conditional can ...

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