+ 1

what is a sematic error? can you please give and example. and is x+y=z; a sematic error?

28th Sep 2016, 3:43 PM
Devang Shukla
Devang Shukla - avatar
2 Answers
+ 7
Nope... there is a difference between semantic and syntax error. Semantic errors are the one where the commands written are not meaningful. For eg. In your case, x+y can not come to the left of the assignment operator z. Hence the correct statement is z=x+y. Whereas a syntax error is the one where a grammatical rule of c++ is violated. For eg. cin<< a is wrong.
28th Sep 2016, 4:13 PM
Devansh Kaushik
Devansh Kaushik - avatar
- 2
semantic error is nothing but a syntax error
28th Sep 2016, 3:50 PM
Suhail Pappu
Suhail Pappu - avatar