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.
2 votes 2 votes if it is i++ in place of &i then answer will be 10 ?? rajan answered Nov 16, 2016 rajan comment Share Follow See 1 comment See all 1 1 comment reply saurabh rai commented Nov 16, 2016 reply Follow Share yes bcoz both(i++ and &i ) have 2 tokens. 5 votes 5 votes Please log in or register to add a comment.
1 votes 1 votes 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. Deepak Gupta 1 answered Mar 24, 2017 Deepak Gupta 1 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes printf("i=%d, &i=%x", i, &i); has 10 tokens Hira Thakur answered Nov 16, 2015 edited Oct 2, 2016 by Hira Thakur Hira Thakur comment Share Follow See 1 comment See all 1 1 comment reply amarVashishth commented Nov 16, 2015 i edited by amarVashishth Nov 16, 2015 reply Follow Share it is not appearing as it should, why?? 0 votes 0 votes Please log in or register to add a comment.