Logic error

Logic errors tend to be more common during the testing phase but do appear in other phases as well. They also tend to be much more difficult to spot and solve. Logic errors will not be picked up by the compiler so the code will compile fine. When the code is run, however, it will display bizarre or incorrect properties. Consider the code below

IF A<10 then PRINT “A is larger than 10”

This code complies with the grammar of the language and will compile correctly. Look carefully at the condition A<10 and also at the print PRINT “A is larger than 10”. What is happening is that we are looking for values less than 10 but displaying that they are greater than 10. This is clearly incorrect. The result would mean that the code would display incorrect values. This is a typical example of a logic error. Simply the programmer has put a less than instead of a greater than.

Logic errors are easy to introduce but very hard to find. This is where debug tools are needed to aid the programmer in solving the problem. It is also why it is important to test your code in a structured and thorough manner.

Logic errors tend to appear -