retagged by
3,504 views
6 votes
6 votes

 

retagged by

7 Answers

0 votes
0 votes
OPTION C, is the answer.

Because an identifier must always start with an underscore or a letter. Since  (1ab2) starts with a number, it obviously gives a lexical error.

Other explaination:

Since OPTION A is correct, A and D are ruled out.

and in OPTION B, (in t a b;), we get 5 tokens.
0 votes
0 votes
  • Lexical : name of some identifier typed incorrectly

  • Syntactical : missing semicolon or unbalanced parenthesis

  • Semantical : incompatible value assignment

  • Logical : code not reachable, infinite loop

0 votes
0 votes

Option C, int 1ab2;, has a lexical error during compilation.

In C and many other programming languages, variable names must begin with a letter or an underscore and can be followed by any combination of letters, digits, and underscores. The variable name 1ab2 starts with a digit, which is not allowed. Therefore, the compiler will report a lexical error during the compilation process.

Option A, int a b;, and option B, in t a b;, both have syntax errors but not lexical errors. In both cases, there is a missing comma between the two variable names, which violates the syntax rules of C. Therefore, the compiler will report a syntax error during the compilation process.

Therefore, the correct answer is option C, int 1ab2;.

Related questions

0 votes
0 votes
2 answers
1
Mohit Aggarwal asked Dec 1, 2021
1,395 views
what is the difference between lexical error and syntax error?
12 votes
12 votes
5 answers
2
Shubhanshu asked Jan 31, 2018
7,199 views
int main() { int 1a, b; Printf("\nGate 2018"); Printf("%d",x); }How many types of error are there in this code?
1 votes
1 votes
3 answers
4
shikharV asked Nov 19, 2015
2,456 views
Given answer: DPlease explain