+ 1

difference between syntax and semantic errors

1st Feb 2017, 4:30 PM
Prabal Titus
Prabal Titus - avatar
2 Respuestas
+ 3
syntax error means when rules of a programming language is violated. ex- int a,b: there is semicolon is missing. AND semantics error means when the statement are not meaningful. ex 2=a; this should be a=2;
1st Feb 2017, 5:13 PM
Wazed Ali Gazi
Wazed Ali Gazi - avatar
0
Syntax is the grammar of the language, so when it is a syntax error, you didn't type it right. Example: Say you forgot to end a statement with a ';' in C++, that is syntax error. Semantic is when everything works except the result that you are tryna get from the program isn't right. Example: You were trying to make a calculator, but when you make it add 1 + 1, it doesn't get the right answer. So the program isn't written in the right way. Edit: I know this is kinda late, but I have a better explanation If you are familiar with word, think of syntax error as spelling errors and think of semantic errors as grammar errors, For example: Syntax/Spelling error: I like cheees Semantic/Grammar error: I am very best //No Syntax/Spelling error but still doesn't make sense
7th Feb 2017, 4:35 AM
Dawzy
Dawzy - avatar