in Compiler Design edited by
1,670 views
4 votes
4 votes

Is the given answer correct?

in Compiler Design edited by
1.7k views

3 Comments

edited by
it is 34
"printf("%d%d%d,a,b,c")" is 14 tokens
1
1
21????
0
0
reshown by
I also write 21 but made easy people counted each token of that statement individually

I think their solution is wrong..!!
0
0

3 Answers

7 votes
7 votes
Best answer

Total 34

"printf("%d%d%d,a,b,c")" 


will be considered as

"printf("      %      d         %         d        %          d      ,        a         ,        b       ,     c             ")"

NOT as 1 token but as 14 token

selected by

4 Comments

Where do u got that concept of 6 token?

Any reference?
0
0

 srestha  may be i am wrong here but i think anything come between " " is a token.Please correct me i am wrong.

0
0
yes, then how u divide  inside "...." and considered it separately?

Even in the selected ans of this question also considered 14 token, how?
0
0
10 votes
10 votes

Yes 34 is correct.

1 comment

Thanku very much :)
1
1
0 votes
0 votes

Tokens:

1:: int  

2:: main 

3,4:: (  )

5,6::{ }

7::int

8,9,10:: a,a,a

11,12,13:: b,b,b

14,15,16::c,c,c 

17-24::=,,,,,;;;

25-30:: %%%ddd

31:: =

32:: +

33:: "printf("

34:: ")" 

Source: http://www.personal.kent.edu/~rmuhamma/Compilers/MyCompiler/chapter3.htm

Coreect me if I'm wrong!

Answer: