91热爆

What is a computer program?

We often think that 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 and we call the list of instructions a computer .

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.

Back to top

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.

Story structure

A computer program also needs to have certain structures to make sure it can it can give the outcome the 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

Back to top

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!

Back to top

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:

  1. Move the empty bottles automatically around the different sections
  2. Fill up the bottle
  3. 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?

Back to top

Watch: Find out more about sequencing

This film from 91热爆 Teach gives more examples of how computers use sequencing in the real world.

91热爆 Teach video

Back to top

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:

  1. Walk up to a toy on the floor
  2. Pick up the toy
  3. 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 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 instruction like this:

Repeat 20 times:

  1. Walk up to a toy on the floor
  2. Pick up the toy
  3. 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.

Back to top

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.

Back to top

Activity: Quiz

Back to top

Computing - Dance Mat Typing. game

Build and test your computing skills with different levels of touch type challenges

Computing - Dance Mat Typing
Back to top

More on Computer science

Find out more by working through a topic