TOPIC 2.3.1
Errors and Bugs


It is important to understand that a program which runs is not necessarily error-free. There are two major types of errors which one can make while writing a program. These consist of errors and bugs. Errors will cause the program not to compile, while bugs are usually logic errors or other hidden problems. An error can consist of small typing mistake, or forgetting a brace at the end of a loop. While bugs usually consist of problems that will let the program run, but run incorrectly. For example letting a loop iterate to many times, evaluating an arithmetic expression in the wrong order, or even forgetting to print important information to the screen.

Can you find the two bugs in this code, which should print out the numbers from 1 to 10?

int count;

count = 1;

while(count < 10);
{
   cout<<count;
}
Solutions: