A token is the smallest meaningful unit of a C program recognized by the compiler. A C program is made up of different types of tokens such as keywords, identifiers, constants, strings, operators and special symbols.
A token is the smallest meaningful unit of a C program recognized by the compiler. A C program is made up of different types of tokens such as keywords, identifiers, constants, strings, operators and special symbols.
Tokens are the basic building blocks of a C program. Just as words and punctuation form a sentence, tokens form a C program.
In the above statement:
| Token | Type |
|---|---|
int |
Keyword |
sum |
Identifier |
= |
Operator |
a |
Identifier |
+ |
Operator |
b |
Identifier |
; |
Special Symbol / Punctuator |
| Type | Meaning | Examples |
|---|---|---|
| Keywords | Reserved words with a fixed meaning in C. | int, if, return |
| Identifiers | Names given to variables, functions and other program elements. | sum, main, count |
| Constants | Fixed values that do not change during program execution. | 10, 3.14, 'A' |
| Strings | Sequence of characters written inside double quotes. | "Hello", "BCA" |
| Operators | Symbols used to perform operations. | +, -, = |
| Special Symbols | Symbols used to structure and separate parts of a program. | ;, {}, (), [] |
Keywords are reserved words of the C language that have predefined meanings. They cannot normally be used as names of variables or functions.
int, if, else,
while, return, for
Identifiers are names used to identify program elements such as variables, functions and arrays.
| Valid | Invalid |
|---|---|
total |
2total |
student_name |
student-name |
marks1 |
int |
Constants are fixed values used in a program. Their value remains unchanged while the program is running.
Integer: 25
Decimal: 3.14
Character: 'A'
A string is a sequence of characters enclosed in double quotation marks.
"Hello"
"BCA Study Portal"
Operators are symbols used to perform operations on values or variables.
| Operator | Example | Purpose |
|---|---|---|
+ |
a + b |
Addition |
- |
a - b |
Subtraction |
* |
a * b |
Multiplication |
/ |
a / b |
Division |
= |
a = 10 |
Assignment |
Special symbols help define the structure and separation of statements and blocks in a C program.
| Symbol | Common Use |
|---|---|
; |
Ends a statement. |
() |
Used with functions and expressions. |
{} |
Defines a block of statements. |
[] |
Used for arrays. |
, |
Separates items such as variables or function arguments. |
| Token Type | Remember |
|---|---|
| Keyword | Reserved word |
| Identifier | Name given by programmer |
| Constant | Fixed value |
| String | Characters inside double quotes |
| Operator | Performs an operation |
| Special Symbol | Helps structure the program |
Watch a beginner-friendly explanation of C tokens and their different types.
▶ Watch: C Tokens — Keywords, Identifiers, Constants & Operators
A short handwritten-style revision sheet for C Tokens will be provided here.
Use the mind map for quick revision of the six types of C tokens.