What is the earliest stage compiler error for the following C code snippet:
int x = @33;
The lexical analyser will catch this error
as we know in any valid assignment numbers must belong to (0-9), @ is an illegal character
Read more from here : https://www.geeksforgeeks.org/lexical-error/
Answer: Option A) Lexical Error
The compiler will show a lexical error because of the "@" symbol in $@33$. It is not a valid character for variable assignment in the C programming language. An identifier can only have alphanumeric characters (a-z , A-Z , 0-9) (i.e. letters and digits) and underscore $(\_)$ symbol.
Thanks,Just to comfirm "int a = Y34_" lexical won't catch this right?
@Souvik33 Yes, it will not generate lexical error because the variable name "Y34_" is a valid token. It will be raised as a semantic error
Thanks @Abhrajyoti00
64.3k questions
77.9k answers
244k comments
80.0k users