How many tokens will be generated by the scanner for the following statement x…

2014

How many tokens will be generated by the scanner for the following statement

x = x * (a + b) − 5;

  1. A.

    12

  2. B.

    11

  3. C.

    10

  4. D.

    07

Attempted by 95 students.

Show answer & explanation

Correct answer: A

To count tokens, identify each individual element separated by spaces or operators. The statement contains identifiers x, a, b; operators =, *, +, −; literals 5; and delimiters (, ), ;. Counting these distinct elements yields a total of twelve tokens.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor