retagged by
48,101 views
58 58 votes

The number of tokens in the following C statement is

printf("i=%d, &i=%x", i, &i);
  1. $3$
  2. $26$
  3. $10$
  4. $21$

Related Questions :

9 Answers

Best answer
84 84 votes

answer - C

Tokens are:

  1. printf 
  2. (
  3. "i=%d, &i=%x"
  4. ,
  5. i
  6. ,
  7. &
  8. i
  9. )
  10. ;
edited by
13 13 votes

printf("i=%d,&i=%x",i&i);  it has 9 token but option are not matching 

the same question came in gate 2001  
printf("i=%d,&i=%x",i,&i); with this statement it has 10 token

1.printf 
2.(
3."i=%d,&i=%x"
4.,
5.i
6.,
7.&
8.i
9.)
10.;

12 12 votes

print =  token1

(   =  token2

"i=%d%x"  =  token3 ////anything inside "  " is considered as 1 token

,   =   token4

i = token5

, = token6

&  = token7

i = token8

) = token9

; = token10

so total 10 tokens

5 5 votes

1.printf
2.(
3."i=%d, &i=%x"
4.,
5.i
6.,
7.&
8.i
9.)
10.;
option C

 

2 2 votes
if it is  i++   in place of &i   then answer will be 10 ??
1 1 vote
Number of tokens(i.e valid lexemes that matches with their pattern ) are

 1)printf   

2). (

3)"i=%d, &i=%x"

4.) ,

5) i

6) ,

7) &

8) i

9) )

10) ;

Hence ,total no of tokens =10  ,Answer C is correct.
Answer:
Position:
Show:

Related questions

51 51 votes
8 answers 8 answers
17.1k
17.1k views
Kathleen asked Sep 14, 2014
17,098 views
A multiset is an unordered collection of elements where elements may repeat any number of times. The size of a multiset is the number of elements in it, counting repetiti...
80 80 votes
4 answers 4 answers
31.5k
31.5k views
Kathleen asked Sep 14, 2014
31,511 views
Consider the following C declaration:struct { short x[5]; union { float y; long z; } u; )t;Assume that the objects of the type short, float and long occupy $2$ bytes, $4$...
40 40 votes
9 answers 9 answers
16.6k
16.6k views
Kathleen asked Sep 14, 2014
16,603 views
Given the following expression grammar:$$\begin{align}E &\to E * F \mid F + E \mid F \\[1em]F &\to F - F \mid id\end{align}$$Which of the following is true?$*$ has higher...
40 40 votes
9 answers 9 answers
14.4k
14.4k views
Kathleen asked Sep 22, 2014
14,404 views
The range of integers that can be represented by an $n$ bit $2’s$ complement number system is:$-2^{n-1} \text{ to } (2^{n-1} -1)$$-(2^{n-1} -1) \text{ to } (2^{n-1} -1)$$...