Skip to content
← Back to Community
4.1 Exercise
Profile icon

In this program, your goal is to identify and correct 5 errors in the program. You will need to "Fork" the program or simply just start editing it and it will automatically make a copy of it in your account.

In general there are four types of errors:

A logic error is a mistake in the algorithm or program that causes it to behave incorrectly or unexpectedly. These are usually the most difficult to find. The program compiles and executes correctly, but the output is not as intended.
A syntax error is a mistake in the program where the rules of the programming language are not followed. Usually the program will not compile if it has syntax errors.
A run-time error is a mistake in the program that occurs during the execution of a program. Programming languages define their own run-time errors. An example of a run-time error is division by zero. The program will compile but execution fails when the run-time error is encountered.
An overflow error is an error that occurs when a computer attempts to handle a number that is outside of the defined range of values. This type of error usually produces strange number values, such as a negative when the value should be positive.
Here are some strategies that are useful in finding and correcting errors:

using a broad range of test cases
hand tracing the code
debuggers - use the IDE tools available
adding extra output statement(s)
For this activity, there are only syntax errors in the program, but in the future you are bound to experience them all.

Profile icon