Nearby lessons

15 of 124

C - 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 ;, ,, {, }, (, )
In simple words: every C program is a sequence of tokens. Keywords are the special tokens the language has already claimed for itself; identifiers are the names you invent.
Common Mistake: thinking 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.

In simple words: keywords are the fixed vocabulary of the C language. You cannot rename them, and you cannot use them as your own names.

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
Trainer's Note: "32 keywords" is the ANSI C / C89 answer, and it is the number exams ask for. Later standards added a few more — 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:

Common Mistake: int if = 5; is wrong — if is a keyword. The compiler will reject it with something like error: expected identifier before 'if'.
In simple words: keywords are like reserved parking spots — you cannot park your own variable there.

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.

Example04
CCode Cell
1#include <stdio.h>
2 
3int main() {
4 int marks = 90; // 'int' is a keyword, 'marks' is an identifier
5 int Int = 5; // legal! C is case-sensitive, 'Int' is not a keyword
6 
7 if (marks > 40) { // 'if' is a keyword
8 printf("Pass\n");
9 }
10 
11 // int if = 5; <-- would not compile: 'if' is reserved
12 
13 printf("Int = %d\n", Int);
14 return 0;
15}
Output
Pass
Int = 5
📝 Key Takeaways
  • 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

🧠 Test Your Knowledge

5 Questions
Progress: 0 / 5