How do we get computers to do what we want?

Have you ever wondered how your computer, phone or games console works?

It is all down to programming. A computer program is a series of algorithms written in a language that tells a computer what to do.

Programs have to be very precise because computers can’t think for themselves. They are great at following instructions but computers will follow instructions even if they are wrong. The best programs are often those which use the quickest possible way to complete a task.

Sequences - what comes first?

Instructions usually have to be completed in the correct order. Computers can’t normally work out this order for themselves, so you need to program them so that they know what to do.

If you don’t get the order right when writing your program, computers can make silly mistakes.

When you get dressed in the morning, you know that you put on your underwear first and your clothes afterwards. There is an order, or ‘sequence’, to follow.

But, unlike you, computers don’t have common sense. They need to be told the right sequence or they will make mistakes.

You know that you put on your underwear first and your clothes afterwards. If you do those tasks in the wrong order you might end up looking like a superhero!

Repetition - let's do it again

Computers can repeat the same task over and over again without getting bored like we do. They are very good at this and always do it perfectly. It would take a very long time to program computers if we couldn't tell them to repeat things.

Imagine you were going to tell your little sister to clean up your room and you had to give her instructions. You would have to say:

  1. Walk up to a toy on the floor.

  2. Pick up the toy.

  3. Put the toy in the toy box.

You would have to say that for every item on your bedroom floor. If your room was very messy it could take a very long time. If we use a ‘loop’ we can tell our computer, or little sister, to repeat the task 20 times or until the floor is clear.

  1. Repeat until the floor is clear.

  2. Walk up to a toy on the floor.

  3. Pick up the toy.

  4. Put the toy in the toy box.

A group of school children use sequence, selection and repetition to create a racing game.

Selection - what should I do?

Computers need to be programmed to tell them how to make decisions. They have to know what to do in many different situations. They have to make a choice or a 'selection'.

Being able to run different code in different situations is what makes computer programs so powerful and flexible.

If you were getting up in the morning you might think, 'Do I have to go to school today?' That decision is affected by the day of the week. If it is a weekday, you will get up and go to school. If it is the weekend, you will stay at home.

Computers use words like IF, THEN and ELSE to help them make decisions.

If a computer was going to school, it would work through the steps in the program to help it to decide what to do.

IF it is a weekday

THEN I will go to school

ELSE I stay at home because it’s the weekend

ELSE is a computer's way of saying 'instead'.

You can use selection to work out what to do in the morning. If it's a weekday, go to school. If it's the weekend, you can stay at home and have a lie-in.

Find out below about sequence, selection and repetition in computer programs.

How a lift works

A lift has examples of sequence, selection and repetition.


How a lift moves and operates is an example of a sequence. The lift will slow and stop at a floor and then open the doors.


The computer that controls the lift has to make decisions. For example, IF a button is pressed THEN the lift will travel to that floor.


A lift will always repeat the instruction: 'check if the button is pressed'.

Test your maths and times table skills!