成人快手

Selection in programmingIF statements

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.

Part of Computer ScienceProgramming

IF statements

consist of a set of 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 .

For example, this simple prints out a message depending on how old you are:

  1. Ask how old you are
  2. 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 , the algorithm would look like this:

A flowchart asking for your age will only give the response 'you are aged to perfection' if the condition met is that you are over 70 years old.
Figure caption,
In programming, selection is implemented using an IF statement