221 views

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?

1. 5 Identifiers
2. 3 literals
3. 4 Identifiers
4. 6 literals
| 221 views
0
4 identifier, 3 literals
0
Ashwini are u considering x as two literals?
0

Ashwani Kumar 2 why considering x as 2 identifiers?

0
Why will be only 3 literals?
0
$5,10,3$
0
So, The answer should be 3 identifiers and 3 literals.
0
Constant literals: 5, 10, 3

Identifiers: x, y, z

x should be counted once...
0
0
I think it should be 3,3
0
What is the number of tokens here ???
0
18 (if we don't count *z as one, I am unsure about that)
0

manisha11 *z is not one token $18$ is correct

+1
Okay
and what if it is x +=  y?
we will count that as 3/4?
0
$3,$ += counted as single assignment operator
0
Thanks a lot!
0
what will be answer for this acc to me it is 3 identifier 3 literals  18 tokens please verify

+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
by Active (1.7k points)