What is a computer program?

We often think that computerA device that processes information by following a set of rules called a program. and computing devices are really clever.
Sometimes we think they are more intelligent than people!
They can complete lots of tasks that people can't do and do them quicker and more accurately than us. They are very good at doing more than one thing at a time.


But remember that computers can't think for themselves. They can only do what people tell them to do. We give them instructions written in a language called codeA language that a computer can understand. and we call the list of instructions a computer programA sequence of instructions written in a coding language that a computer can understand..
Computing devices have a memory, where they can store programs and other information.
We write a computer program because we want a computer or computing device to complete a task. This task might be part of a larger project, or it might be a way to solve a problem.
Computer programs and stories
When we write a story, we know it must have certain structures to make it work for the reader.
The story will have events, or things that happen in a particular order, or sequence. We call this the plot, and the sequence is usually the beginning, followed by the middle and finally the end.
The story will also usually include descriptions of the characters and the story setting.


A computer program also needs to have certain structures to make sure it can it can give the outcome the computer programmerSomeone that creates programs for a computer. intended.
Some of the important structures that make up a computer program are:
The order, or sequence of the instructions
Whether any of the instructions are repeated

Sequences - what comes first?
The sequence, or order of the instructions in any task is important.
If things are in the wrong order, the outcome of the task won't be what you wanted.
Let's look at an everyday example where the sequence of instructions is important to achieve the correct outcome - a neatly folded T-shirt!
Computers and sequences

Unlike people, computers can't tell if something is in the wrong place in a sequence. It will just carry on running the program, even if things start to go wrong.
This means we have to make sure we check our algorithms and then our program code to see if everything is in the correct sequence.

Let's look at a real-world example
In a drinks factory, the machines are all controlled by computers. The machines:
- Move the empty bottles automatically around the different sections
- Fill up the bottle
- THEN put the lids on
Can you describe what would happen if they got the computer program sequence wrong and put the lids on first?

Watch: Find out more about sequencing
This film from BBC Teach gives more examples of how computers use sequencing in the real world.
BBC Teach video
NARRATION: When we say sequencing, what do we mean? Well, in everyday terms we mean the correct order in which something should happen. So, let’s talk about putting your socks and shoes on. There is a right way and a wrong way to do this, and the order - or sequence - is important. I mean, you wouldn’t try and put your shoes on then try and put your socks on, would you? Because frankly, that just ain’t going to work.
The more complicated the task, the more important the sequence becomes. We also need to make sure those instructions have all the right details. It’s like me asking someone to assemble my perfect sandwich and them putting in all the wrong ingredients in the wrong order, and it ends up looking like this tragic looking effort here. I would need to give them a detailed sequence of instructions so that I don’t end up with that. With food we call that list a recipe. So here it goes…
First, take the bread roll and slice it down the middle… nooo, not that way! Rewind… take the bread roll and slice it horizontally across, yes like that. Now, take the lid off the butter and take a knife and scrape some of the butter onto the inside of the bread bun… excellent. Now for the lettuce and some tomatoes… add the lettuce to the bottom of the bread bun… no, not underneath it. On top of it… seriously! Anyway, you get the picture. If you don’t do everything in the correct order and with all the right details then the end result won’t be what you want.
Let’s think about how this works with computers. We call the list of instructions for a computer a program, rather than a recipe. But the idea is the same. The problem is, computers don’t know when they have been given the wrong instructions, or if the steps are in the wrong sequence. It just goes on following the program anyway. When we carry out a task we can use our initiative to fix problems as they come along.
Imagine a computer program that tells the robotic machines in a fizzy drink factory how to fill up the bottles on the conveyor belt. If the instruction sequence in the program isn’t in the correct order, and it puts the lids on before it fills up the bottles, then we would not only be left with empty bottles but a whole lot of cleaning up! So, we can see that sequencing is an important part of writing useful computer programs that help computer-controlled devices to do the jobs we planned.
Writing programs for your own computer games is a good way to practice your sequencing skills and get everything in the right order. This game needs you to get the mini-me to jump over the zombie piranhas and walk across the bridge to the other side. Now, if I wrote the program with the steps out of sequence, and I asked it to walk first then jump, then I'd end up gobbled up by the zombie piranhas!
It is the same principle when we look at the incredible computerised robots that build cars. These robots carry out thousands of movements and tasks to build each car, and everything needs to be precise and in sequence. It’s a bit like dancers working together on a complicated dance sequence, everyone needs to know their moves and everyone needs to perform them in the correct order.
And if we think even bigger than that, then just imagine how precise the sequencing needs to be in the hundreds of different computer programs that control a rocket launch. There can’t be any errors in all those instructions, everything needs to be in the right order and with all the right details. This means the programs must be tried and tested over and over again to make sure everything works as planned.
The power of getting things in exactly the right order is absolutely crucial when writing computer programs, so it’s clear to see just how important sequencing is when it comes to computers and also ourselves. After all, nobody wants wet socks!
Repetition - let's do it again
Repeating something, or doing the same thing more than once, can be a good way to learn or remember something new.
Imagine you were going to show an alien how to help tidy up your room. You would have to give them careful instructions.
You could say:
- Walk up to a toy on the floor
- Pick up the toy
- Put the toy in the toy cupboard

But there are 20 things to tidy up - you must have been very untidy lately.
You could just repeat the same CommandA single instruction - when part of a computer program. 20 times, but it would take a long time to tell the alien the same instructions over and over again.
Nearly as long as it would take to tidy your room!
If the alien was a robot you could use a repeatTo do something more than once. instruction like this:
Repeat 20 times:
- Walk up to a toy on the floor
- Pick up the toy
- Put the toy in the toy cupboard
The repeat command turns the instruction list into a repeat loop, where we go round and round the loop 20 times.
Repeat loops in computer programs

Computers can repeat the same task over and over again without getting bored or tired like we do.
It's one of the things that makes them so useful.

We can add REPEAT commands to our computer programs. This saves time and makes our program more efficient by using fewer lines of code.

We usually put the REPEAT command and the number of times to repeat it before the instructions themselves.
You can see the difference in the length of this program for our alien.
Activity: Quiz
SATs preparation resources. activitySATs preparation resources
Get ready for the SATs papers with videos, activities, quizzes and games to refresh your knowledge and practise your skills.

More on Computing science
Find out more by working through a topic
- count3 of 11
- count4 of 11
- count5 of 11
- count6 of 11