When programmers write code in a high-level language there are two types of errors that they might make: syntax errors and logic errors.
Syntax errors are mistakes such as misspelled keywords, a missing punctuation character, a missing bracket, or a missing closing parenthesis. Nowadays, all famous IDEs such as Eclipse, NetBeans, and Visual Studio (to name a few) detect these errors as you type and underline the erroneous statements with a wavy line. If you try to execute a program that includes syntax errors, you will get error messages on your screen and the program won’t be executed. You must correct all the errors and then try to execute the program again.
Logic errors are those errors that prevent your program from doing what you expected it to do. With logic errors you get no warning at all. Your code may compile and run but the result is not the expected one. Logic errors are the most difficult errors to detect. You must revisit your program thoroughly to determine where your error is. For example, consider a program that prompts the user to enter three numbers, and then calculates and displays their average value. The programmer, however, made a typographical error; one of his or her statements divides the sum of the three numbers by 5, and not by 3 as it should. Of course the program is executed as usual, without any error messages, prompting the user to enter three numbers and displaying a result, but obviously not the correct one! It is the programmer who has to find and correct the erroneously written statement, not the computer or the compiler!
This article is taken from a book of mine. If you enjoyed it, please visit my author's page inand check out all of my books!