41 votes 41 votes The number of tokens in the following C statement is printf("i=%d, &i=%x", i, &i); $3$ $26$ $10$ $21$ Compiler Design gatecse-2000 compiler-design compiler-tokenization easy isro2015 + – Kathleen asked Sep 14, 2014 retagged Dec 4, 2022 by Lakshman Bhaiya Kathleen 36.4k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Amrata Ramchandani 1 commented Oct 26, 2017 reply Follow Share Is white space considered as a token ? and if yes doesn't the above programs have 2 white spaces : 1) after string constant 2) after variable i ? 0 votes 0 votes ankitgupta.1729 commented Jun 23, 2018 reply Follow Share In C , whitespace is not considered as a token class... 0 votes 0 votes meghna commented Sep 19, 2018 reply Follow Share A good read on lexemes, tokens and patterns https://stackoverflow.com/questions/14954721/what-is-the-difference-between-a-token-and-a-lexeme 4 votes 4 votes vishalshrm539 commented Sep 22, 2018 reply Follow Share WhiteSpaces will be removed by the lexical analyser from the source code, this is one of the jobs of LA. 1 votes 1 votes Please log in or register to add a comment.
Best answer 57 votes 57 votes answer - C Tokens are: printf ( "i=%d, &i=%x" , i , & i ) ; ankitrokdeonsns answered Nov 23, 2014 edited Dec 4, 2017 by kenzou ankitrokdeonsns comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments tusharp commented Nov 22, 2018 reply Follow Share here the identifier 'i' will be counted as many times as it appears in the source code, but will be given only one token number in the symbol table? Yes 0 votes 0 votes tusharp commented Nov 22, 2018 reply Follow Share There is line of declaration and line of usage column in symbol table. There just the line number where occurrence of i is used/declared can be given. 0 votes 0 votes tusharp commented Nov 22, 2018 reply Follow Share http://arantxa.ii.uam.es/~modonnel/Compilers/04_SymbolTablesI.pdf 0 votes 0 votes Please log in or register to add a comment.
12 votes 12 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.i6.,7.&8.i9.)10.; Umang Raman answered Oct 11, 2015 Umang Raman comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments abby murali commented Oct 13, 2015 reply Follow Share Thanks for the reply... Actually my doubt is about the quotes (" " ) shouldn't we count that also...? 0 votes 0 votes Umang Raman commented Oct 13, 2015 reply Follow Share C tokens are of six types. They are, Keywords (int, while,etc), Identifiers ( main, total,etc), Constants ( 10, 20), Strings ( “total”, “hello”), Special symbols ( (,), {,} etc), Operators ( +, /,-,*,etc) 22 votes 22 votes neethu_seb commented Dec 2, 2019 reply Follow Share printf("i=%d,&i=%x",i&i); --- comma is missing, that is why geetting 9 as count. 0 votes 0 votes Please log in or register to add a comment.
11 votes 11 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 Tauhin Gangwar answered Jun 7, 2016 Tauhin Gangwar comment Share Follow See all 0 reply Please log in or register to add a comment.
5 votes 5 votes 1.printf 2.( 3."i=%d, &i=%x" 4., 5.i 6., 7.& 8.i 9.) 10.; option C Umang Raman answered Nov 2, 2015 Umang Raman comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments Arjun commented Jun 4, 2016 reply Follow Share it is an operator- returns the address of operand. 3 votes 3 votes Ram Sharma1 commented Jun 18, 2016 reply Follow Share Okey 0 votes 0 votes rajatmyname commented Sep 4, 2016 reply Follow Share Arjun Sir, In the complete reference it has discussed three types of reference-VARIABLE,NUMBER and DELIMITER.Is it correct or the above types of tokens is right? 0 votes 0 votes Please log in or register to add a comment.