Explain logical error.

4 views

1 Answers

A logic error is a defect in the program that causes it to produce an incorrect result, but one that is not so blatant as to be detectable as a runtime error. (A logic error in one part of the program might eventually trigger a runtime error in some other part of the program, but those are separate errors.) An example would be a function that is supposed to return the larger of its two arguments but in fact, returns the smaller: 

def larger(m, n): 

if (m > n): 

return n 

return m

4 views