12. How Do I Test Several Things at Once?

With Logical Operators

image

Sometimes the relational operators described in Chapter 11, “How Can I Compare Two Values?,” simply can’t express all the testing conditions. For example, if you wanted to test whether a numeric or character variable is within a certain range, you would have to use two if statements, like this:

image

Although there’s nothing wrong with using nested if statements, they’re not extremely straightforward and their logic ...

Get Absolute Beginner’s Guide to C, 2nd Edition 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.