Runtime Error vs Logic Error
People think a program that runs to the end with no message is working, and it may not be. A runtime error stops the program while it runs and names the line, such as a divide by zero. A logic error stops nothing. The program finishes and the answer is just wrong. Only a check of the result will catch it.
Runtime Error
An error that shows up while the program runs. Some input sets it off.
A runtime error happens while the program is running. The code is written right, so it starts. Then it hits something it cannot do. Dividing by zero, opening a file that is not there and using a null value are common causes. The program stops at that line and shows a message. Often it only happens with certain input, so it can hide for a long time.
Logic Error
Code that runs with no error message but gives the wrong answer.
A logic error is a mistake in the thinking behind the code. The program runs to the end with no message at all. It simply gives the wrong answer. Putting steps in the wrong order or using > where you meant >= are common causes. These are the hardest errors to find, because nothing tells you they are there.
In one line
- Runtime Error
- An error that shows up while the program runs. Some input sets it off.
- Logic Error
- Code that runs with no error message but gives the wrong answer.