4 identifier, 3 literals

5 votes

Consider the following code

$x = (y + 5) + (^*z) * 10 - x /3 $

Which of the following correctly identified by lexical analysis after scanning the above code?

- 5 Identifiers
- 3 literals
- 4 Identifiers
- 6 literals

1 vote

x=(y+5)+(∗z)∗10−x/3

Here, Identifiers are X, Y, Z.

Literals are constant numbers 5, 10, 3.

Wheras the rest are operators.

So, answer is 3 Identifiers and 3 Literals.

Refer this, https://www.cse.iitk.ac.in/users/karkare/cs335/lectures/04LexicalAanalysis.pdf

Here, Identifiers are X, Y, Z.

Literals are constant numbers 5, 10, 3.

Wheras the rest are operators.

So, answer is 3 Identifiers and 3 Literals.

Refer this, https://www.cse.iitk.ac.in/users/karkare/cs335/lectures/04LexicalAanalysis.pdf