More than One Way to Handle Conditions

Programs must be able to make decisions based on conditions. It is not unusual to be confronted with a task that involves what is called conditional processing, which is the ability to determine which direction to take the program based on a value or a set of conditions. If X value is true, then do Y. If it is false, then do Z. If Ralph has a grade point average of B or better, then put him in the scholarship program. If it is not equal to or better than B, then don’t put him in the scholarship program. These are the kinds of real-life situations that you can encounter. In short, you need to have the ability to control your program. You have already been introduced to the following flow control structures, ...

Get Access 2002 Programming by Example 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.