Previous PageNext Page

Common mistakes in the use of the IF-THEN structure
Recall that the task as defined in the first slide in this chapter was:
"... to write a recoding algorithm that assigns below 65 to F, below 70 to D, below 80 to C, below 90 to B, and 90+ to A."
Are the following two statements equivalent?

     IF 0 LE Score LT 65 THEN Grade='F';
     IF      Score LT 65 THEN Grade='F';

The first statement is interpreted by the compiler as:

	IF (0 LE Score) and (Score LT 65) THEN Grade='F';

So the second form of the IF is equivalent only if 0 LE Score is always true. Is it?
It may help to think of

       0 LE Score

as its equivalent

       SCORE GE 0

So, is it possible to get scores less than zero? Is "scores are always greater than or equal to zero" always true?

Previous PageTable Of ContentsNext Page