retagged by
18,487 views

3 Answers

Best answer
22 votes
22 votes
Actually there are 12 tokens.
they Left semi colon (;)  ..
selected by
11 votes
11 votes
We may a have a confusion of slecting && a single token or & as 2 diff token

Similarly the same thing goes for + or ++

The concept that come "MAximal match ".If you have + and may with one look ahead you have encountered ++ then in that case you will take maximal one . ie ++ so it would be considered ++ as token under relational operator token class

similarly a & is address operator and && is a logical so you take max of both of them so its &&

Now but in case of *** you cant have "all" of them as a single token . or we dont have any opearator (***) -we are extending the indirection property .There is no such token class , Infact each of * will come under one token class . SO all 3 in one token class

So the token are printf

c

"what up %id "

,

++

&&

*

*

*

a

)

;

ALl of these counts to 12 ! :)
4 votes
4 votes

/* abc*/ gives 0 token bcz lexical analyzer avoid the comment 

printf count as 1 token

(   count as 1 token

"whats up %d" count as 1 token

 ,count as 1 token

++ is increment operator so count as 1

&& is also logical AND operator so count as 1

*** are count as 3 token

a     count as 1 token 

) count as 1 token 

; count as 1 token so 

tatal 12 token plz correct me if i am wrong

Answer:

Related questions

0 votes
0 votes
1 answer
1
syncronizing asked Sep 21, 2018
5,275 views
Question:Find the number of tokens in the following C code using lexical analyzer of the compiler.
0 votes
0 votes
2 answers
2
saumya mishra asked Jun 12, 2018
2,173 views
In this question we will take n-=n1 as n=n-n1 as 5 tokens or n-=n1 as 4 tokens ????
2 votes
2 votes
4 answers
4