edited by
5,006 views

3 Answers

6 votes
6 votes

$\underline{\textbf{Answer:}\Rightarrow}\;\mathbf{c.}$

The number of tokens are:

  1. switch
  2. (
  3. inputvalue
  4. )
  5. {
  6. case
  7. 1
  8. :
  9. b
  10. =
  11. c
  12. *
  13. d
  14. ;
  15. break
  16. ;
  17. default
  18. :
  19. b
  20. =
  21. b
  22. ++
  23. ;
  24. break
  25. ;
  26. }
edited by
1 votes
1 votes

The tokens in the code segment are as follows:

  1. switch - Keyword
  2. ( - Punctuation
  3. inputvalue - Identifier
  4. ) - Punctuation
  5. { - Punctuation
  6. case - Keyword
  7. 1 - Integer Literal
  8. : - Punctuation
  9. b - Identifier
  10. = - Operator
  11. c - Identifier
  12.  Operator
  13. d - Identifier
  14. ; - Punctuation
  15. break - Keyword
  16. ; - Punctuation
  17. default - Keyword
  18. : - Punctuation
  19. b - Identifier
  20. = - Operator
  21. b - Identifier
  22. ++ - Operator
  23. ; - Punctuation
  24. break - Keyword
  25. ; - Punctuation
  26. } - Punctuation

Therefore, the number of tokens in the given C code segment is 26.

 

 

Answer:

Related questions

3 votes
3 votes
4 answers
1
Satbir asked Jan 13, 2020
8,874 views
A given grammar is called ambiguous iftwo or more productions have the same non-terminal on the left hand sidea derivation tree has more than one associated sentencethere...
5 votes
5 votes
4 answers
2
Satbir asked Jan 13, 2020
3,712 views
In a two-pass assembler, resolution of subroutine calls and inclusion of labels in the symbol table is done duringsecond passfirst pass and second pass respectivelysecond...
3 votes
3 votes
3 answers
3
Satbir asked Jan 13, 2020
3,722 views
Given the grammar$s \rightarrow T ^{\ast} S\ \mid T$$T \rightarrow U+T\ \mid U$$U \rightarrow a \mid b$Which of the following statements is wrong?Grammar is not ambiguou...
1 votes
1 votes
3 answers
4
Satbir asked Jan 13, 2020
2,251 views
A grammar is defined as$A \rightarrow BC$$B \rightarrow x \mid Bx$$C \rightarrow B \mid D$$D \rightarrow y \mid Ey$$E \rightarrow z$The non terminal alphabet of the gram...