Computer Science, asked by manisha3710, 11 months ago

Difference between syntax and semantics error with example

Answers

Answered by PSN03
7

Syntax error:

The errors which are caused by using invalid statements or trying to perform an operation which actually isn't valid. In simple words we can say that its incorrect with respect to the grammar of coding.

for ex: if we try to multiply a string with an integer or float in C

or

trying to use indexing in python

Semantic errors:

These statements follow the grammar of the coding language but give undesired results which the user didn't expect. They are caused by the mistake of user

Ex:

a='hello'

print(b)   #b isn't declared

Hope this helps.

Answered by fatimakhalid070782
1

Answer:

a='hello'

print(b) #b isn't declared

Similar questions