Nearby lessons
15 of 124C - Keywords
Keywords are the words C has already claimed for itself — int, if, for, return and 28 others. They have a fixed meaning and cannot be used as your own variable or function names. This lesson places keywords among the five kinds of token, lists all 32 grouped by purpose, and clears up the most common confusion: main is not one of them.
Tokens — The Building Blocks
A C program is made of small pieces called tokens. Keywords are one of the five types — the table shows where they fit:
| Token type | Meaning | Example |
|---|---|---|
| Keywords | Words with fixed meaning in C | int, float, if, return |
| Identifiers | Names given by the programmer | sum, marks, studentName, main |
| Constants | Fixed values that do not change | 10, 3.14, 'A', "Hello" |
| Operators | Symbols that perform operations | +, -, *, /, = |
| Special symbols | Punctuation that structures the code | ;, ,, {, }, (, ) |
main is a keyword. It is not — main is an ordinary identifier. It is special only because the operating system looks for a function with that name to start the program. Nothing stops you from writing int main_menu(), but you could never write int if().
What are Keywords?
A keyword is a word that C has already reserved for a special meaning. For example int means integer type, if means decision, and return means send a value back.
Keywords are also always lowercase. C is case-sensitive, so int is the keyword but INT and Int are not — they are just ordinary names you could use as your own.
The 32 Standard Keywords
ANSI C (C89) defines exactly 32 keywords. Grouped by what they are for, they are much easier to remember than one long alphabetical list:
| Category | Count | Keywords |
|---|---|---|
| Data types | 5 | int char float double void |
| Type modifiers | 4 | signed unsigned short long |
| Type qualifiers | 2 | const volatile |
| Storage classes | 4 | auto register static extern |
| Control flow | 11 | if else switch case default break continue for while do goto |
| User-defined types | 4 | struct union enum typedef |
| Others | 2 | return sizeof |
| Total | 32 |
inline and restrict in C99, _Bool, _Static_assert and others in C11 — so a modern compiler knows more than 32. If a question does not name a standard, answer 32.
Why Keywords Matter
You cannot use a keyword as a variable name, function name, or anything else you invent:
int if = 5; is wrong — if is a keyword. The compiler will reject it with something like error: expected identifier before 'if'.
If you really want a name close to a keyword, change the case or add a word: Int, ifCondition and my_class are all valid identifiers.
- Keywords are words with a fixed meaning reserved by C
- They cannot be used as variable or function names
- ANSI C (C89) has exactly 32 keywords; later standards added a few more
- main is NOT a keyword — it is an identifier
- C is case-sensitive — INT is not the keyword int