teach-ict.com logo

THE education site for computer science and ICT

3. Selection in an algorithm

The algorithm on the previous page had each operation occuring one after another with no deviation at all.

This is a very unlikely situation in most algorithms.

It is normal to have some kind of decision being made within the algorithm. For instance in english the rule below is applied

'if this situation is true then do this, otherwise do that'

You can see the next instruction to be processed depends on some condition being true or not. This is called 'selection'.

Selection is such a common requirement that every computer language has a way of coding for it. These are called 'conditional statements'

The next few pages describes the most common forms of selection statements.



Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: C language syntax