Computer Science
Logical Error
A logical error is a mistake in the program's logic that causes it to behave unexpectedly or produce incorrect results. It is a type of programming error that occurs when the code does not follow the intended logic or algorithm. Logical errors are difficult to detect and fix because the program may still run without crashing.
Written by Perlego with AI-assistance
Related key terms
1 of 5
5 Key excerpts on "Logical Error"
- eBook - ePub
Instant Approach to Software Testing
Principles, Applications, Techniques, and Practices
- Dr Anand Nayyar, Anand Nayyar(Authors)
- 2019(Publication Date)
- BPB Publications(Publisher)
16 ]. Introduction of errors in a software program is subject to human mistakes and can be classified as follows:- Logical Error: Missing or inadequate or unclear interpretation in the source code.
- Message error: Compiler error messages for the source code that are misinterpreted.
- Navigation error: Moving from one function to another function is not correctly coded.
- System error: Memory leak, hardware, and operating system related errors.
- Incorrect requirements: Incorrect or wrong requirements.
- Performance error: Anything related to the performance leads to performance error.
- Data error: Incorrect data update in the database due to wrong data types used.
- Database error: Improper normalization of database schema/design.
- Standards: Standards not followed like improper exception handling, improper coding/design standards.
- Incorrect design: Wrong or incorrect design.
- Typographical error: Grammatical/lexical mistake in documents/source code.
- Comments: Comments in the source code are not properly mentioned.
- Variable declaration error: Wrong declaration/usage of variables in the source code, mismatch in data types of variables.
- Boundary value analysis error: Boundary conditions are not coded properly.
- Complexity error:
- eBook - PDF
Miscommunications
Errors, Mistakes, Media
- Timothy Barker, Maria Korolkova, Timothy Barker, Maria Korolkova(Authors)
- 2021(Publication Date)
- Bloomsbury Academic(Publisher)
Semantic and Logical Errors can be found later—in the testing phase or even when the program has already been sold. Runtime errors will show up even later and lead to bigger problems with the code execution. Like logical and semantic errors, they mostly do not lead to a program crash but to unwanted/unexpected program behavior. They only appear when the running program is fed with data that the programmer did not consider: a sensor value beyond the defined range, an input that leads to a miscalculation, a software conflict (e.g., with a peripheral driver), an outdated operating system, or similar problems. This kind of error shows most clearly the failure of every programmer’s goal: the reduction of a real‐world problem into an algorithm, which of course assumes that he/she knows or can find all the main facets of that real‐world problem. Unfortunately, most of these facets only reveal themselves when the program has already hit the “real world”—after its publication. Big efforts have been made to research and teach ways to avoid programming errors. Since programming languages are counted among the formal languages, their behavior can be predicted perfectly. There are programming languages, like Ada, whose effects can be calculated and proven mathematically, programs that help to detect errors with built in proving tools, 6 and external tools for monitoring the running program down to a single step line‐by‐line execution of the code (with the so-called debuggers ). Even fault tolerance is programmable with operations and routines that trap errors and call specific routines to compensate their effects. The main goal remains in avoiding and removing errors, which requires compliance with programming rules (cf. Grams 1990: 5f.), like commenting the code, using clear structures (to make the code maintainable for others), and regularly checking for new demands of the operating system and its environment. - Joyce Farrell(Author)
- 2012(Publication Date)
- Cengage Learning EMEA(Publisher)
Testing the Program A program that is free of syntax errors is not necessarily free of Logical Errors. A Logical Error results when you use a syntactically correct statement but use the wrong one for the current context. For example, the sentence The dog chases the cat , although syntactically perfect, is not logically correct if the subject turns out to be a fox or if the cat is the aggressor. Once a program is free of syntax errors, the programmer can test the program — that is, execute it to determine whether the output is correct or whether Logical Errors exist. If the program does not require any input but simply displays some output, you can read the output and determine whether it shows what you wanted and expected. Many programs, however, require that you enter some data, so you must enter sample data and see whether the results are logically correct. Recall the number-doubling program: input myNumber myAnswer = myNumber * 2 output myAnswer If you execute this code, provide the value 2 as input to the program, and the answer 4 is output, you have executed one successful test run of the program. However, if the answer 40 is output, maybe the program contains a Logical Error. Maybe the second line of code was mistyped with an extra zero, so that the program reads: input myNumber myAnswer = myNumber * 20 output myAnswer Placing 20 instead of 2 in the multiplication statement caused a Logical Error. Notice that nothing is syntactically wrong with this version of the program — it is just as reasonable to multiply a number by 20 as by 2 — but if the programmer intends only to double myNumber , then a Logical Error has occurred. Programs should be tested with many sets of data. For example, if you write the program to double a number, then enter 2 and get an output value of 4, that doesn ’ t mean you have a correct program.- eBook - PDF
- Allegra Via, Kristian Rother, Anna Tramontano(Authors)
- 2014(Publication Date)
- Chapman and Hall/CRC(Publisher)
Logical Errors mean that your program fin-ishes normally, but the results are wrong because the program does something different from what you had in mind. You will learn strate-gies that help you write programs that contain fewer errors and where errors are easier to find. When you get stuck despite these efforts, it is time to ask for help (see Box 12.1). To learn to know all aspects of debugging, you will analyze a broken program. The program is supposed to sort dendritic lengths from a text BOX 12.1 ASK FOR HELP Debugging is difficult. Many programmers say it is much more difficult than programming itself. When you are fully immersed into your code, it can be hard to spot the problem. When you are stuck, you get lost in details and overlook things obvious to other people. In that situation a fresh pair of eyes often helps. That fresh pair of eyes could belong to the following: • An experienced programmer. They like to solve difficult problems. • A similarly experienced colleague to whom you can explain the program . The explanation often helps you find where your thoughts might have taken a wrong turn. Or your colleague might come up with a good question that leads you to the wrong piece of code. • A nonprogrammer . Explaining what you are trying to do to a nonpro-grammer requires you to simplify conceptually, and this might help you as well. • Yourself. You may simply overlook an easy programming bug because you are tired. If you are fighting with the same error for more than 20 minutes, it is time for a break. Not a break on your web browser. A real break. Switch off the screen, and come back after a while. Then consider again what your program should do, and then take a look to see whether it really does that. Admitting that you are stuck at the moment and talking to another per-son are often the fastest ways to get a hint that solves the problem right away, or they allow you to take a deep breath and approach your code with fresh energy. - eBook - PDF
- Joyce Farrell(Author)
- 2012(Publication Date)
- Cengage Learning EMEA(Publisher)
Although making errors is never desirable, syntax errors are not a major concern to programmers because the compiler or interpreter catches every syntax error and displays a message that notifies you of the problem. The computer will not execute a program that contains even one syntax error. 8 C H A P T E R 1 An Overview of Computers and Logic Copyright 2012 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s). Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it. Typically, a programmer develops a program ’ s logic, writes the code, and then attempts to compile or interpret the program using language-interpreting software. Usually, the software displays a list of syntax errors, which the programmer corrects. Then, the programmer attempts another translation. Correcting the first set of errors frequently reveals new errors that originally were not apparent to the compiler. For example, if you could use an English compiler and submit the sentence the dg chase the cat , the compiler at first would point out only one syntax error to you. The second word, dg , is illegal because it is not part of the English language. Only after you corrected the word dog would the compiler find another syntax error on the third word, chase , because it is the wrong verb form for the subject dog . This doesn ’ t mean chase is necessarily the wrong word. Maybe dog is wrong; perhaps the subject should be dogs , in which case chase is right. Compilers don ’ t always know exactly what you mean, nor do they know what the proper correction should be, but they do know when something is wrong with your syntax.
Index pages curate the most relevant extracts from our library of academic textbooks. They’ve been created using an in-house natural language model (NLM), each adding context and meaning to key research topics.




