answersLogoWhite

0


Best Answer

Syntax Error: error due to missing colon, semicolon, parenthesis, etc. Syntax is the way in which we construct sentences by following principles and rules.

Example: In C++, it would be a syntax error to say

int x = "five";

This will not compile because it does not follow the syntax of the language and does not make any sense to the compiler.

Semantic Error: it is a logical error. it is due to wrong logical statements. Semantics is the interpretations of and meanings derived from the sentence transmission and understanding of the message. Semantics errors are Logical, while Syntax errors are code errors.

Example: A semantic error would compile, but be incorrect logically:

const int pi = 12345;

Your program will likely compile and run without error but your results will be incorrect. (Note that these types of errors are usually much harder to debug)

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

A semantic error is one related to the meaning of something. For example, a syntactically perfect statement made in the wrong context is a semantic error which may be detected at compile-time. On the other hand, misinterpreting a variable of a generic type (e.g. int) as a temperature value in Kelvin when it really holds units of Celsius is a semantic error which may not be detected at compile-time.

A logic error is one that refers to an incorrect program logic. For example, the following pseudocode snippet contains a logic error:

if (a > b) {

print("a is greater than b"); } else { print("a is less than b");}

(The error is that the second branch is true if a is less than or equal to b.)

Most compilers detect only few logic errors, but some sophisticated tools exist which can subject source code to very thorough examination, allowing the detection of such errors with a higher probability at compile-time. PC-Lint is an example for such a (commercial) tool.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

Semantics errors are Logical, Syntax errors are code errors.

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

A syntax error is when the Asians rebooted the mother drive an made Koreans

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Difference between semantic error and logical errors?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How computer handle semantic error?

Semantic error are logical errors. That does mean, it would compile and run without errors. But, the output would be different from the expected output.


What is lexical and semantic errors?

cars was


How do you understand errors?

Errors are bugs or mistakes.It coulb be syntax or semantic in nature.


What is the difference between a compilation error and logic error?

errors which come during compilation is known as compilation error. here we get syntax errors only not logical errors like division by zero. logical error occur during run time example:if you write a program for division with zero you will not get compilation error but during execution you will error


What is Semantic errors in c?

A semantic error is a logic error. That is, the code may compile and run, but does not perform as you intended. Some semantic errors can be picked up by the compiler, often shown as warning, such as: if (x = 5) // warning: did you mean x == 5? Others are simply impossible for the compiler to spot: int x, y, z; // ... ++z; // add 1 to x In the above code, we meant to increment x, but incremented z instead. The compiler won't notice the error so this will inevitably lead to a runtime error.


What are mistakes that cause a running program to produce incorrect results called?

Semantic errors


Why do humans make logical errors in problem solving and decision making?

humans do logical errors in problem solving and decision making because of non-existence of sufficient ....WISDOM.


What is the difference between ECC and parity memory?

ecc momory can detect and repair errors


What is the difference between prespective and descriptive linguistics and what do you focus on?

The distinction is between prescriptive and descriptive grammarians, not linguists. The former point out errors. The latter call errors correct, if they are common enough.


Three types of program errors and examples?

Syntax errors: errors due to the fact that the syntax of the language is not respected.(The first type of error is a syntax error. You already know that syntax errors are caused when you don ' t obey the syntax rules of C#. A common syntax rule you might make in the beginning is forgetting to terminate each program statement with a semicolon. Intellisense does an excellent job of catching syntax errors. While you may hate the squiggly linethat Intellisense displays, it ' s a lot easier for Intellisense to detect and isolate syntax errors than it is for you to do it yourself.)Semantic errors: errors due to an improper use of program statements.( Logic errors are those errors that remain after all the semantic and syntax errors have been removed. Usually, logic errors manifest themselves when the result the program produces doesn ' t match the result your test data suggest it should produce. Most of the time, logic errors are found in the Process . Logic errors occur when you implement the algorithm for solving the problem incorrectly. The key to fixing logic errors is to be able to reproduce the error consistently. A repeatable logic error is much easier to track down and fix than an error that appears to be occurring randomly. you will learn the details of using some of the tools Visual Studio provides to help you detect and isolate program bugs.))Logical errors: errors due to the fact that the specification is not respected(A semantic error occurs when you obey the syntax rules of the language but are using the statement out of context. For example, a sentence in English is expected to have a noun and a verb. Consider the sentence " The dog meowed. " This sentence does obey the rules of having a noun and a verb, but the context of the sentence is out of whack. Dogs don ' t meow, therefore the context of the statement is incorrect. The error message I showed you earlier: The name 'i' does not exist in the current context refers to a type of semantic error. There may well be a variable named i defined somewhere in the program, but it is not currently in scope. That is, you are trying to use i when it is out of scope.Intellisense does a good job of detecting semantic errors.)


Which of the following can be a result of a person's logic containing errors that weaken his or her argument?

A logical fallacy


Example of semantic errors?

scores = [51, 47, 53, 97, 27]summation = 0.0for score in scores:summation *= score # Semantic Error.average = summation / len(scores)print average # Isn't average. average == 0