Question 1
2 marksDescribe what is meant by selection in a program.
Model answer
Selection is when the program tests a condition, and the result (True or False) decides which block of code is run next, so some code may be skipped. In OCR Exam Reference Language it is written with if ... then ... else ... endif or switch ... case.
Explanation
Selection lets a program make decisions. A condition such as age >= 18 is evaluated, and the program follows one branch if it is True and another (or none) if it is False. Selection does not repeat code - that is iteration - and code in a branch that is not chosen does not run at all.
Mark scheme
-
1 mark
a condition is tested / evaluated (as True or False)
Accept 'a decision is made using a Boolean expression'.
-
1 mark
the result decides which block of code / path is run (and other code is skipped)
Accept 'the program branches'. An example such as if ... then ... else on its own scores 1 mark at most.