When designing programs, there are often points where a decision must be made. This decision is known as selection, and is implemented in programming using IF statements.
programSequences of instructions for a computer. consist of a set of instructionA single action that can be performed by a computer processor. that are carried out one after another. Sometimes there may be more than one path (or set of steps) that can be followed. At this point, a decision needs to be made. This decision is known as selectionA decision within a computer program when the program decides to move on based on the results of an event..
For example, this simple algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs. prints out a message depending on how old you are:
Ask how old you are
IF you are 70 or older, say 鈥淵ou are aged to perfection!鈥
The selection comes in step 2. If you are aged 70 or over, one message is displayed.
As a flowchartA diagram that shows a process, made up of boxes representing steps, decision, inputs and outputs., the algorithm would look like this: