BCA / B.Tech 10 min read

Tokens & Keywords in C

Tokens in the C Language:


In the C language, "tokens" are used as the smallest symbolic elements of code. These tokens are of various types and are used for different tasks during programming. Tokens are a significant component of code and determine the structure of the program.

Types of Tokens:
Keywords: Special words that are predefined for the C language (e.g., `int`, `if`, `while`).
Identifiers: User-defined names for data elements like variables, functions, or arrays.
Literals: Constant values that are written directly in the program (e.g., 10, 'A', "Hello").
Operators: Special symbols that define various actions (e.g., +, -, *, =).
Special Symbols: Special characters used for specific tasks in the program (e.g., `{}`, `()`, `;`).

Importance of Tokens: They determine the program's structure, improve code readability, and help in error detection.

Keywords in the C Language:


Keywords in programming languages are special words that play a specific role in the language. These words are predefined and have a special meaning. They cannot be used in any other way, such as for variable names. C has 32 standard keywords, including `int`, `float`, `if`, `while`, `return`, etc.