![]() |
VOOZH | about |
C keywords are reserved words that have predefined meanings recognized by the compiler. They form the basic building blocks of the C language and cannot be used as identifiers such as variable names, function names, or structure names.
Successful demonstration of keywords.
Using a keyword as a variable name results in a compilation error because keywords are reserved by the language.
Output:
error: expected identifier before 'return'
The following are the most commonly used keywords in C.
Used to declare variables and define the type of data they can store.
| Keyword | Usage |
|---|---|
| char | Declares a character data type. |
| int | Declares an integer data type. |
| float | Declares a single-precision floating-point type. |
| double | Declares a double-precision floating-point type. |
| void | Specifies no value or return type. |
| short | Declares a short integer. |
| long | Declares a long integer. |
| signed | Declares a signed data type. |
| unsigned | Declares an unsigned data type. |
Used to control the execution flow of a program.
| Keyword | Usage |
|---|---|
| if | Executes code when a condition is true. |
| else | Executes code when an if condition is false. |
| switch | Selects one block from multiple choices. |
| case | Defines a branch inside a switch statement. |
| default | Executes when no case matches. |
| for | Creates a for loop. |
| while | Creates a while loop. |
| do | Creates a do-while loop. |
| break | Terminates a loop or switch statement. |
| continue | Skips the current loop iteration. |
| goto | Transfers control to a labeled statement. |
| return | Exits a function and optionally returns a value. |
Used to define the scope, lifetime, and visibility of variables.
| Keyword | Usage |
|---|---|
| auto | Declares an automatic local variable. |
| register | Requests storage in a CPU register. |
| static | Preserves variable value between function calls. |
| extern | Refers to a variable defined elsewhere. |
Used to create custom data types.
| Keyword | Usage |
|---|---|
| struct | Defines a structure. |
| union | Defines a union. |
| enum | Defines an enumeration. |
| typedef | Creates an alias for an existing data type. |
Used to modify the behavior of variables.
| Keyword | Usage |
|---|---|
| const | Makes a variable read-only. |
| volatile | Indicates that a variable may change unexpectedly. |
| restrict | Specifies exclusive access to an object through a pointer (C99). |
Used for low-level programming and compiler-specific operations.
| Keyword | Usage |
|---|---|
| sizeof | Returns the size of a data type or object in bytes. |
Keyword Vs Identifier