C Tokens, Keywords and Identifiers etc
Last Updated : Jan 2026
Let's try to understand the smallest meaningful pieces of C code.
Tokens
A token is the smallest meaningful unit of a C program recognized by the compiler. For example:
int age = 20;
// Don't worry what this is for now,we will study it later,for now just try to understand it
This line can be broken into:
int
age
=
20
;
Each is a token. Think of a sentence:
I am learning C.
It contains individual words and punctuation.
Types of C Tokens
C tokens can broadly be classified as:
C Tokens
│
├── Identifiers
├── Keywords
├── Constants
├── Operators
└── Punctuators / Special Symbols
We'll understand each of them one by one,but we'll learn more about each in upcoming sections.
Identifiers
An identifier is a name given by the programmer to a program element. Examples:
age, price, studentName, total, marks, calculate
These names can be used for things such as:
- Variables
- Functions
- Structures
- Other user-defined entities
For example:
int age;
Here:
age → identifier
The programmer chose the name age to store an value so we can easily communicate. It is just like :
In math we write
x=10,
y=20,
z=30
when we need 10,20,30 we just write x,y,z respectively.Here
x,y,z → identifiers
10,20,30 → values/data
Note : when we combine identifiers and values/data we call it variable.
int age = 20;
int months = 5;
Rules for Identifiers
- Identifiers must begin with a letter or an underscore.
- Never start with a number but number can be after letters or underscores.
- Identifiers are case-sensitive.
- Spaces are not allowed.
- Can not redeclare an identifier with the same name.
- Identifiers cannot be keywords.
e.g:
Valid Identifiers: age, studentAge, student_age, marks1, totalMarks, _private
Invalid Identifiers:1age, student age, student-age, int, float
because of:
1age → starts with digit
student age → contains space
student-age → '-' is not allowed in an identifier
int → keyword
float → keyword
Case-Sensitivity: age, Age, AGE, aGe
age ≠ Age ≠ AGE ≠ aGe
Keywords
A keyword is a reserved word that has a predefined meaning in C. For example:
int
means something specific to the compiler. You cannot normally use int as your own identifier name. For example:
int int = 10;
is invalid. Why? Because int already has a special meaning.
Some Common C Keywords
You don't need to memorize all of them right now.
int, char, float, double, void
if, else, switch, case, default
for, while, do
break, continue, return
struct, union, enum
const, static, extern
sizeof, typedef
We'll learn these gradually.
Constants
A constant is a value that does not change during the relevant execution/context of the program. For example:
int age = 10
// 10 is a constant
There are several types of constants:
- Integer Constants (Whole Numbers)
- Floating-Point Constants (Real/Decimal Numbers)
- Character Constants (Single Character)
- String Constants (Text) (Sequence of characters)
We'll study constants in much greater detail later. For now:
10, 20, 100, 3.14, 'A',"Hello"
are examples of literal constant values.
Operators
Operators are symbols that tell C to perform operations. For example:
a + b
Here:
a → operand
+ → operator
b → operand
Some common operators:
+, -, *, /, %, =, ==, >, <, &&, ||, !
We'll have an entire section dedicated to operators.
Punctuators / Special Symbols
C uses various symbols to structure programs. Examples:
;
,
( )
{ }
[ ]
#
For example:
int age = 20;
; → semicolon
Let's Break Down a Complete Statement
Consider:
float price = 99.50;
Tokens:
float
price
=
99.50
;
Classification:
float → keyword
price → identifier
= → operator
99.50 → floating-point constant
; → punctuator
Whitespace and Tokens
Consider:
int age = 20;
The spaces help us visually separate tokens:
int
age
=
20
;
The compiler uses lexical rules to identify these tokens. This is why:
int age=20;
can still be valid. The spaces aren't always required between every token. But readable formatting is strongly recommended.
A Useful Mental Model
Think of C code like a sentence.
C Program
↓
Statements
↓
Tokens
↓
Characters
For example:
int age = 20;
Statement
↓
Tokens
↓
int | age | = | 20 | ;
↓
Characters
This is roughly how the compiler begins understanding your source code.
Till now: We learned about symbols,variables, keywords, constants, operators, punctuators and whitespace.Remember what is our learning flow:
Symbol → token → Instruction → Program
So Next Topic is Introduction. we will discuss about it in next section
