The number of tokens in the following C code segment is switch (inputvalue) {…

2025

The number of tokens in the following C code segment is

switch (inputvalue)

{

case 1 : b = c * d ; break ;

default : b = b++ ; break ;

}

  1. A.

    27

  2. B.

    29

  3. C.

    26

  4. D.

    24

Attempted by 54 students.

Show answer & explanation

Correct answer: C

To count tokens, identify keywords like switch and case, identifiers like inputvalue, operators such as = and *, punctuation including braces and semicolons, and constants. Counting each distinct element sequentially in the provided code segment yields a total of 26 tokens.

Explore the full course: Mppsc Assistant Professor