91热爆

Spelling mistake on

What causes a computer bug?

When we learn to write a story, we sometimes make mistakes. We might make a spelling mistake by typing letters in the wrong order. We might put a sentence in the wrong place which will make our story confusing.

It's the same when we learn to write a computer program. We make mistakes.

Mistakes in a computer program are called bugs.

Remember - it's okay to make mistakes when you are learning. Almost every computer program will have a bug in it at some point. Finding and fixing these bugs helps us to learn.

Spelling mistake on
Back to top

Watch: What are computer bugs?

Back to top

How do we know when we have a bug?

We write a computer program to give instructions to a computer or digital device.

We might want to:

  • make a cartoon mouse jump on the computer screen
  • make a robot move around a map on the floor

We know we have a bug in our program if the computer or digital device doesn't complete the task as we expected when we tell it to GO.

The cartoon mouse might walk instead of jumping! The robot might go backwards instead of forwards.

Back to top

How do we find the bug?

We must find the bug in our program and fix it. We can follow these steps to help us find bugs:

  • Watch what our computer or device does when we tell our program to GO.
  • Look at each little step to see if our computer or device is doing the right thing.
  • Check to see if the mistake is at the beginning or near the end.

This is called testing our program.

Back to top

How do we fix the bug?

We know what went wrong so now we can find the bug in our program that caused the problem and fix it. It's just like when we correct our spelling mistakes when we write a story.

Maybe we chose the walk block instead of the jump block for our cartoon mouse program.

Maybe we put the movement arrows in the wrong order in our robot program.

We can fix our program by removing the bug and replacing it with the correct instruction.

We also need to check all the instructions are in the right order.

Then we can test our program again to see if it works.

Do you think the mouse will jump this time?

Back to top

Glossary

Here are the meanings of some important words:

Computer 鈥 A device that can follow instructions stored in its memory.
Digital device 鈥 A machine that has a computer inside.
Robot 鈥 A machine with a computer inside.
Screen 鈥 A device that shows pictures, text, videos and animations.
Algorithm 鈥 A list of instructions that completes a task or solves a problem.Program 鈥 A list of instructions a computer can understand.
Bug 鈥 A mistake in a computer program.

Back to top

Activities

Back to top

Play Bitesize Primary games. game

Fun and educational primary games in science, maths, English, history, geography, art and design, computing and modern languages.

Play Bitesize Primary games
Back to top

More on Computing science

Find out more by working through a topic