retagged by
5,581 views
6 votes
6 votes

retagged by

3 Answers

Best answer
22 votes
22 votes
1xab - is not a valid token in C (as variable names cannot start with a digit and numbers cannot have a letter other than 'x' (for hex) or 'l' (for long) and also not a valid keyword) and hence lexical error. It could have been x1ab, _x1ab etc. both would have given a semantic error for variable not defined.
selected by
3 votes
3 votes

It is a lexical error at earliest as we can see that the token "1xab" will be treated as an identifier ..But we know as per standard naming convention in C language , the variable name cannot begin with "1" ..

So it will be an invalid token..Hence the error concerned will be lexical error at the earliest..

Hence A) is correct answer..

0 votes
0 votes
Lexical analyser scan the program and generate token store into symbol table and return token id.
Token may be
Keyword
Identifier(function or variable)
Operators
Special symbols.
So 1xba not any things
So it produces Lexical error

Related questions

0 votes
0 votes
2 answers
1
Mohit Aggarwal asked Dec 1, 2021
1,327 views
what is the difference between lexical error and syntax error?
6 votes
6 votes
7 answers
2
Na462 asked Oct 5, 2018
3,409 views
12 votes
12 votes
5 answers
3
Shubhanshu asked Jan 31, 2018
7,013 views
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); }How many types of error are there in this code?
7 votes
7 votes
4 answers
4
itsvkp1 asked Nov 1, 2017
3,205 views
if there is miss spelling in some keyword in a program then this misspelled keyword will be treated as lexical errors or it will be treated as a new identifier and accept...