The Gateway to Computer Science Excellence
+4 votes
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
in Compiler Design by Boss (35.8k points) | 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
answer given is 4 Identifiers
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 Answer

+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)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,645 questions
56,596 answers
195,824 comments
102,084 users