Difference between semantic error and logical errors?

1 answer

Answer

1171309

2026-04-19 23:00

+ Follow

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)

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.