C Notes
Complete guide to all 32 keywords in C programming — categorized by purpose with explanations, usage examples, and comparison tables.
Every programming language has a set of words with predefined meanings that you cannot use for your own purposes. In C, these are called keywords (also known as reserved words). They form the core vocabulary of the language — the building blocks from which all C programs are constructed.
C has exactly 32 keywords (as defined by the ANSI C89/C90 standard). Each keyword has a specific purpose and cannot be used as a variable name, function name, or any other identifier.
Complete List of 32 C Keywords
Here is the full list of keywords in C, grouped by their function:
| Category | Keywords |
|---|---|
| Data Types | int, float, double, char, void |
| Type Modifiers | short, long, signed, unsigned |
| Storage Classes | auto, register, static, extern |
| Type Qualifiers | const, volatile |
| Control Flow | if, else, switch, case, default |
| Loops | for, while, do |
| Jump Statements | break, continue, goto, return |
| Structure/Union | struct, union, enum, typedef |
| Miscellaneous | sizeof |
Data Type Keywords
These keywords define what type of data a variable can hold.
int
Declares integer variables (whole numbers).
int age = 25;
int count = -10;float
Declares single-precision floating-point numbers (6-7 decimal digits of precision).
float temperature = 36.6;
float price = 9.99;double
Declares double-precision floating-point numbers (15-16 decimal digits of precision).
double pi = 3.14159265358979;
double distance = 1.496e11; // scientific notationchar
Declares character variables (single byte, stores one character or small integer).
char letter = 'A';
char digit = '7';void
Indicates "no type" or "no value." Used for functions that don't return anything and for generic pointers.
void printMessage() {
printf("Hello!\n");
}
void *genericPointer; // can point to any typeType Modifier Keywords
These modify the range or size of basic data types.
short and long
short int smallNumber = 32000; // at least 16 bits
long int bigNumber = 2000000000; // at least 32 bits
long long int huge = 9000000000LL; // at least 64 bitssigned and unsigned
signed int negative = -50; // can hold negative values (default)
unsigned int positive = 50000; // only non-negative values (0 and above)
unsigned char byte = 255; // range: 0 to 255Size Comparison Table
| Type | Size (typical) | Range |
|---|---|---|
short int | 2 bytes | -32,768 to 32,767 |
int | 4 bytes | -2,147,483,648 to 2,147,483,647 |
long int | 4-8 bytes | At least ±2 billion |
unsigned int | 4 bytes | 0 to 4,294,967,295 |
float | 4 bytes | ±3.4 × 10^38 (6 digits) |
double | 8 bytes | ±1.7 × 10^308 (15 digits) |
Storage Class Keywords
Storage class keywords determine where a variable is stored, its scope, visibility, and lifetime.
auto
The default storage class for local variables. Rarely written explicitly since all local variables are auto by default.
void func() {
auto int x = 10; // same as: int x = 10;
printf("%d\n", x);
}register
Requests the compiler to store the variable in a CPU register for faster access. The compiler may ignore this hint.
You cannot take the address (&) of a register variable.static
Makes a local variable retain its value between function calls. For global variables, static restricts visibility to the current file.
Called 1 times Called 2 times Called 3 times
extern
Declares a variable or function that is defined in another file or later in the same file.
// In file1.c
int globalCount = 0;
// In file2.c
extern int globalCount; // uses the variable from file1.cType Qualifier Keywords
const
Declares a variable whose value cannot be modified after initialization.
const int MAX = 100;
// MAX = 200; // ERROR: cannot modify const variablevolatile
Tells the compiler that a variable's value can be changed unexpectedly (by hardware, interrupt, or another thread). The compiler won't optimize away reads of this variable.
volatile int sensorReading; // might change outside program control
// Used in embedded systems:
volatile int *statusRegister = (volatile int *)0x40001000;Control Flow Keywords
if, else
Conditional branching — execute code based on conditions.
int score = 85;
if (score >= 90) {
printf("Grade A\n");
} else if (score >= 80) {
printf("Grade B\n");
} else {
printf("Grade C\n");
}switch, case, default
Multi-way branching based on integer/character values.
Good job!
Loop Keywords
for
Used when the number of iterations is known in advance.
while
Used when the loop condition is checked before each iteration.
int n = 5;
while (n > 0) {
printf("%d ", n);
n--;
}
// Output: 5 4 3 2 1do
Used with while for a do-while loop — executes at least once.
int num;
do {
printf("Enter positive number: ");
scanf("%d", &num);
} while (num <= 0);Jump Statement Keywords
break
Exits the nearest enclosing loop or switch statement immediately.
continue
Skips the rest of the current iteration and moves to the next.
goto
Transfers control to a labeled statement. Generally discouraged but useful for error handling in system-level code.
0 1 2 3 4 Done!
return
Exits a function and optionally returns a value to the caller.
int add(int a, int b) {
return a + b; // returns the sum
}Structure and Union Keywords
struct
Groups related variables of different types under one name.
union
Similar to struct but all members share the same memory location. Only one member can hold a value at a time.
union Data {
int i;
float f;
char c;
}; // Size = max(sizeof members)enum
Defines a set of named integer constants.
enum Color { RED, GREEN, BLUE };
enum Color favorite = GREEN; // favorite = 1typedef
Creates an alias (new name) for an existing type.
typedef unsigned long int ulong;
typedef struct Student Student;
ulong population = 1400000000;The sizeof Keyword
sizeof is a compile-time operator that returns the size (in bytes) of a type or variable.
int: 4 bytes float: 4 bytes double: 8 bytes char: 1 bytes Array of 10 ints: 40 bytes
Keywords Added in C99 and C11
While the original C89 standard has 32 keywords, newer standards added a few more:
| Standard | New Keywords |
|---|---|
| C99 | _Bool, _Complex, _Imaginary, inline, restrict |
| C11 | _Alignas, _Alignof, _Atomic, _Generic, _Noreturn, _Static_assert, _Thread_local |
These are less commonly tested in exams but important for professional C development.
Interview Questions on C Keywords
Q1: How many keywords are there in C?
The ANSI C89/C90 standard defines 32 keywords. C99 added 5 more, and C11 added 7 more. In exams and interviews, the answer is typically 32 (referring to the original standard).
Q2: Can keywords be used as variable names?
No. Keywords are reserved by the language and cannot be used as identifiers (variable names, function names, etc.). Attempting to do so will cause a compilation error.
Q3: What is the difference between break and continue?
break terminates the entire loop and transfers control to the statement after the loop. continue only skips the current iteration and moves to the next iteration of the loop.
Q4: What is the purpose of the volatile keyword?
volatile tells the compiler that a variable may change unexpectedly (outside the program's control — such as by hardware or another thread). The compiler will not optimize away reads of that variable, ensuring the program always gets the current value from memory.
Q5: What is the difference between struct and union?
In a struct, each member has its own memory location, so the total size is the sum of all members (plus padding). In a union, all members share the same memory, so the size equals the largest member. Only one union member can hold a valid value at any time.
Summary
- C has 32 keywords in the ANSI C89 standard — all lowercase and reserved.
- Keywords are categorized into data types, modifiers, storage classes, qualifiers, control flow, loops, jump statements, and user-defined types.
- You cannot use keywords as variable names or identifiers.
- Understanding each keyword's purpose is essential for writing correct C programs.
- Newer C standards (C99, C11) introduced additional keywords for modern programming needs.
- The
sizeofoperator (technically a keyword) returns the byte size of types and variables at compile time.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Keywords in C Programming.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this C Programming topic.
Search Terms
c-programming, c programming, programming, basics, keywords, keywords in c programming
Related C Programming Topics