1 votes 1 votes Find no of tokens in below program. #include<stdio.h> main() { int I; int *pi = &I; //parent pointer scanf("%d",pi); printf("%d\n", I+5); } Compiler Design compiler-tokenization lexical-analysis + – sagar27 asked Sep 21, 2018 sagar27 5.2k views answer comment Share Follow See all 11 Comments See all 11 11 Comments reply Sayan Bose commented Sep 21, 2018 reply Follow Share L1:main() L2:{ L3: int I; L4: int *pi = &I; //parent pointer L5 : scanf("%d",pi); L6 : printf("%d\n", I+5); L7: } L1 : 3 ; L2 : 1 ; L3 : 3 ; L4 : 7; L5 : 7 ; L6 : 9 ; L7 : 1 So total number of tokens : 31 6 votes 6 votes Prince Sindhiya commented Sep 21, 2018 reply Follow Share I am getting 31 What is answer ? 0 votes 0 votes sagar27 commented Sep 21, 2018 i reshown by sagar27 Oct 13, 2018 reply Follow Share what about header file? 0 votes 0 votes Sayan Bose commented Sep 21, 2018 reply Follow Share Lexical analysis of header file is not done 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share @Sayan Bose Lexical analysis of header file is not done WHY? is there any standard reference? 0 votes 0 votes srestha commented Sep 21, 2018 reply Follow Share @Shaik https://gateoverflow.in/202250/cd-lexical-analysis-token it is true 0 votes 0 votes Shaik Masthan commented Sep 21, 2018 reply Follow Share @srestha mam then how the printf and scanf or some other can resolve? ( i mean at what phase of compiler ) 0 votes 0 votes srestha commented Sep 21, 2018 reply Follow Share @Shaik it is done before lexical analysis In preprocessing phase (macro also done there) 1 votes 1 votes suneetha commented Oct 12, 2018 reply Follow Share i am getting total num of tokens as 32 0 votes 0 votes Aryanishu2000 commented Mar 29, 2020 reply Follow Share References to printf and scanf are actually resolved by the linker by providing the object code for printf and scanf and other library functions. In the preprocessing phase only function prototype are included in source code . So the actual resolving done by linker . That linking again of two types-- Static linking Dynamic linking 0 votes 0 votes Sanandan commented Oct 3, 2020 reply Follow Share Total number of tokens are 31 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes statement # of tokens #include<stdio.h> 0(zero) main() 3 { 1 int I; 3 int *pi = &I; //parent pointer 7 scanf("%d",pi); 7 printf("%d\n", I+5); 9 } 1 Total 31 sudharshan answered Feb 1, 2019 sudharshan comment Share Follow See 1 comment See all 1 1 comment reply PratikDey0316 commented Nov 3, 2020 reply Follow Share @sudharshan We can't say that #include<stdio.h> will have 0 tokens because in the preprocessor stage this header would be expanded to its actual content. And the number of tokens would be huge !!! 0 votes 0 votes Please log in or register to add a comment.