The Gateway to Computer Science Excellence
0 votes
185 views

 

in Compiler Design by Loyal (7k points) | 185 views
0
My answer is 46 is it correct ?

I have counted   -= ----> As a single token , ++ ----> Single token.

Please correct me where i'm wrong if i'm wrong ?
0
Even I'm getting 46
0

 

I have counted   -= ----> As a single token , ++ ----> Single token.

it is correct.

 

But note that in your question, there is a space between - and = ===> those are different tokens.

So, totally 47 tokens exist in this program 

0
@shaik

What if in question

1.int m = -10;

2.int m =- 10;

3. Int m =- -10;

What would be no of token in above 3 cases?

Thanks
+2

@Mayankprakash

1) int,m,=,-,10,;  ===> 6 tokens

2) int,m,=,-,10,;  ===> 6 tokens

3) int,m,=,-,-,10,;  ===> 7 tokens

 

=- ===> can't a pattern in C, therefore those should be different tokens

 

4) int m = --10; ====> -- recognized as single token ==> 6 tokens

0
Thanks Shaik!!
0
46?
0
@Shaik the space between - and = is a misprint else there would have been a lexical error isn't it ?
0
why you this it is mis-print?

if it is mis print then answer is 46, otherwise it is 47

But it can't generate lexical error, it caught at syntax phase
0
Oh yeah syntax error sorry :P

1 Answer

+1 vote
46 tokens as {-= is 1 token , -- is 1 token , ++ is 1 token }.
by Active (3.1k points)
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,737 questions
57,385 answers
198,556 comments
105,368 users