Concept:
A Lexical Analyser (Scanner) breaks the source code into the smallest meaningful units called "Tokens."
• Keywords: Reserved words like int, while, return.
• Identifiers: Names of variables or functions (e.g., x, a).
• Operators: Symbols like =, +.
• Constants/Literals: Numeric values like 10.
• Punctuators: Separators like ;.
Step 1: Scanning the input string.
The string is: int x = a + 10;
Step 2: Identifying each token.
• {int (Keyword)
• {x (Identifier)
• {= (Assignment Operator)
• {a (Identifier)
• {+ (Arithmetic Operator)
• {10 (Constant/Literal)
• {; (Separator/Punctuator)
Step 3: Calculating the total count.
Total tokens = 1 (int) + 1 (x) + 1 (=) + 1 (a) + 1 (+) + 1 (10) + 1 (;)
Total = 7 tokens.