Brothersoft.comWindows|Mac|Mobile|Games

|Message

Solve software problem quickly Share experience to help others Improve the ability of solving problem
Differences Between a Syntax Error and a Logical Error

11/07/2011 02:19 by KevinHan

First answer posted by DanielSimon at 11/07/2011 02:19
Add Your Answer
10~1000 characters in length CAPTCHA:
2 Answers
  • DanielSimon
  • An error can disrupt program flow, create nonsensical results or cause a program to terminate completely. Understanding the differences between syntax errors and logical ones helps the debugging process by making error location a simpler task. Neither type of error is confined to programming, and real-life examples are easy to spot.

    Logic and Syntax

    Think of logic as yes-or-no questions and syntax as the parts of speech. Logic is a progression of conclusions based on simple statements. Complex logic patterns are created by combining a series of statements that define the desired result. Logic statements can be expressed mathematically, but syntax errors cannot. A syntax error is typically an action that is performed unnecessarily, in the wrong order, or completely out of context for the intended use. Syntax errors can be detected by analytical software, while a logical error is difficult for the computer to discern.

    Program Operation and Syntax Errors

    In programming, a syntax error occurs when the program attempts to evaluate a statement and encounters a fuzzy command or impossible statement. One example of a syntax error would be an equation with undefined variables, or a print command without print value. By thinking of syntax as the parts of speech you can understand the importance of proper organization of programming statements. Commands are actions that are performed on the subject of the statement, with additional descriptions and branching commands added to the structure in the form of operands such as AND, OR and WHILE among others, just as they are in speech.

    Logic and Syntax in Real Life

    Logic errors are miscalculations or misinterpretations of events. In many cases, a logical error occurs when a conclusion is drawn without enough supporting evidence. For instance, to assume that the power is off because there are no electric appliances running is a logical error because it contains only an assumption. An electrical short tripping the main breaker is an example of a syntax error, as the system is unable to comply with a total draw to ground.

    Errors and Data Corruption

    If a logical error is written into a program, it has the potential to corrupt data or even cause the program to stop running. Once an incorrect value has been established, the computer will continue to use that value because it is unable to recognize the error and passes it on to the program. This could lead to a corrupt database, faulty calculations or garbled images. Syntax errors can cause data corruption by introducing incorrect commands or premature termination of program execution.

    Logical Errors and Plotting Points

    Geometric functions are particularly susceptible to logic errors. Formulas that involve multiple operands must be carefully evaluated and kept in the correct order of operations. Compound statements involving IF..THEN..ELSE statements may cause data overflow or unexpected plotting results, such as a box that is plotted inversely rather than in forward increments. Because this type of error is a legal equation, the language compiler does not detect the error and it will only become apparent when the program is run.

  • Was this answer helpful? 00 · 11/07/2011 02:19
  • Anonymous user
  • u r such a fool
  • Was this answer helpful? 00 · 12/06/2011 01:45
Add Your Answer
10~1000 characters in length CAPTCHA:
Related Questions
Q:How to Solve a Syntax Error in IE?

A: Open Internet Explorer. Click "Start" and click the "Internet Explorer" shortcut. Click the "Tools" button and then click "Internet Op...(more)

Q:What Is a Syntax Error in Java?

A:Java syntax errors refer to mistakes made by a programmer in implementing the grammar of the Java programming language. It doesn't cover mis...(more)

Q:How to Fix a Syntax Error in Windows Media?

A: Click "Tools" and click "Options." Click "Network," "Streaming Protocols" and check the box next to all listed types. Press "Apply" an...(more)

Q:What is a Syntax Error in a Computer Program?

A:One of the essential concepts any computer programmer must understand is the syntax error. Universal to all programming languages, a syntax ...(more)

Q:How to Fix a Syntax Error Message With Internet Explorer?

A: Launch Internet Explorer. Click on "Tools" in the file menu and select "Internet Options." A dialog box appears. Click the "Font...(more)

Added Successfully!

×

Are you sure to delete your answer?

NoYes

×

Are you sure to choose it as the best answer?

NoYes

×

Voted Successfully!

×

You can't vote for yourself

×

You can't choose your own answer

×