• retagged by
1,321 views
1 1 vote
What is the diffrence between Lexical error , Syntax error and semantic error..?

Please explain with this example

void main()
{
int total-value, Num=2,sum=5,var1;
5=Num;
var1=2;
sum=num*1;
if(sum=var1)
{
sum=sum+1
}
}

1 Answer

0 0 votes

'total-value' is a lexical error. Lexical analyzer won't be able to identify the token.

 

'5=Num;' and 'sum=sum+1' are syntax errors. These tokens don't qualify as valid syntax.

 

'sum=num*1;' is a semantic error as only semantic analyzer will be able to check that 'num' is an undeclared variable.

Position:
Show:

Related questions

3 3 votes
2 2 answers
860
860 views
Kiran Karwa asked Jan 20, 2018
860 views
what type of error is caused if function name is same as a keyword name?
3 3 votes
0 0 answers
1.5k
1.5k views
admin asked Aug 5, 2019
1,474 views
Consult the language reference manuals to determinethe sets of characters that form the input alphabet (excluding those that may only appear in character strings or comme...
1 1 vote
3 3 answers
1.1k
1.1k views
VJ2793 asked Feb 12, 2019
1,136 views
fro(int I=0; I <5;I++);what kind of compilation error is this ?
3 3 votes
1 answers 1 answer
5.5k
5.5k views
radha gogia asked Mar 11, 2018
5,548 views
1. Declaring an array with a floating point subscript : e.g int a[2.8] ;In my opinion ,it should be a syntax error :How will the parse tree be generated ...