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).
Comparison and Logical Operators | |
---|---|
Operator | Meaning |
> | 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 ...
Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.