Skip to main content

4.9) Decisions With More Freedom To Test


We will now add further flexibility to do tests with the If statements. If that first test in Example 8 is not true (line 6) then perhaps you may want to do more tests. In Example 9 I have included an else if statement. If the test on line 6 is not true, now it will jump to the else if (you can write as elseif if you like) on line 8 and it will test that criteria. If a is greater than 4.0 then it goes to line 9 and then jumps to the endif on line 12. If false then it goes to the else (if it reaches the ‘else’ then it always executes what is inside the if statement there on line 11 (you can have many more lines than one if you like). The if statement ends with line 12.

Example 9 appears on the next page.