Please support us

Thursday, July 19, 2012

Differentced between synatax,semantic and logical errors


Among these three types of errors we can identify number of difference such as,

Syntax
Semantic
Logical
Cause because of error in the syntax of a sequence of characters or tokens
Cause because of improper use of program statements
Caused because of wrong programming designing

Syntax errors are occurred when don’t obey the syntax rules in programming. Semantic errors are occurred because of improper use if programming statements. But wrong programming designing is the main reason which leads as the reason for a logical error.

Syntax
Semantic
Logical
Program will not compile until all syntax errors are corrected.
Indicate that the statement is  out of scope
Executed without errors. But, does not generate the requested result.

 Logic errors occur when implement the algorithm for solving the problem incorrectly. But in logical errors it will executed the output without an error. But the thing is, it does not giving the expected output. When concern about the syntax errors we can identify that the program will not compile until all syntax errors are correct. In semantic errors it indicate that the statement is out of scope when there is a semantic error.


Syntax
Semantic
Logical
An error messages 
An error message
Program is compiled and executed without errors

If there is an syntax error it will indicate about this through an error message. If there is a semantic error, there also can see an error message. But not like syntax error or semantic error, According to the logical error the program is compiled and executed without errors. But, does not generate the requested result.

Syntax
Semantic
Logical
Detected by the compiler
May be detected by compiler, linker, run-time
May be  detected at run-time

  Normally Syntax errors are detected by the compiler. Semantic errors may be detected by compiler, linker or semantic errors can detect at run-time. When concern about the Logic errors, we can identify logical errors may be detected at run-time. But sometimes these errors are not detected at all

Syntax
Semantic
Logical
Logical error
WHIL(x<=10)
IF(avg>=70)THE
total=m1+m2+m3
IF(avg>70)THEN
READ “PASS”
ELSE
DISPLAY “FAIL”
END IF
Total=m1+m2+m3
Avg=(m1*m2*m3)/3;
Syntax error
IF(avg>70)THEN
grade= “fail”
ELSE
grade= “pass”
END IF



No comments:

Post a Comment

We need your comments