Tokens
A token is the smallest individual element in a C++ program that has meaning to the compiler.
Example:
int sum = a + b;
Tokens here are:
int | sum | = | a | + | b | ;
Types of Tokens
1. Keywords
Reserved words with predefined meaning.
int, float, if, else, for, while, return, class, namespace
We can’t use these as variable names.
2. Identifiers
Names given by the programmer to variables, functions, classes, etc.
sum, totalMarks, calculateSalary
Rules:
Must start with a letter or
_Can contain letters, digits,
_Cannot be a keyword
3. Literals (Constants)
Fixed values that do not change during program execution.
10 // integer literal
3.14 // floating literal
'A' // character literal
"Hello" // string literal
true // boolean literal
4. Operators
Symbols that perform operations on operands.
+, -, *, /, %, =, ==, <, >, &&, ||
5. Punctuators / Separators (Special Symbols)
Characters used to structure the program.
; , {} () [] ::
Last modified: 08 February 2026