Compound Relational Tests

The if statements you’ve used so far in this chapter set up simple relational tests between two numbers. Program 6.1 compared the value of number against zero, whereas Program 6.2 compared the denominator of the fraction to zero. Sometimes it becomes desirable, if not necessary, to set up more sophisticated tests. Suppose, for example, that you want to count the number of grades from an exam that were between 70 and 79, inclusive. In such a case, you would want to compare the value of a grade not merely against one limit, but against the two limits 70 and 79 to ensure that it fell within the specified range.

The Objective-C language provides the mechanisms necessary to perform these types of compound relational tests. ...

Get Programming in Objective-C, Sixth Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.