Using the IF Command! Go Full Screen to see in greater detail?
|
Often in programming, a decision will have to be taken depending on things such as the answer a user gives to a question. For example, if the traffic lights are green, then you can cross the road. Otherwise, you should wait to cross.
The IF command is used in such cases. This works just as you may well have seen when working with a formula in a spreadsheet or a computed field in a database.
IF THEN ELSE - another way to make a decision! Go Full Screen to see in greater detail?
|
The problem above uses 3 IF commands that will all be tested by the computer.
Here we consider how the use of the Else command can mean that only one conditions may have to be tested by the computer, helping to speed up how quickly a program runs.
Oh! By the way, see if you can spot the deliberate mistake. What should it be?
What you have to do!
Mark off Exercise 10 in your progress grids.
What you should now be able to do!