Keywords
In C programming, keywords are fundamental building blocks. They are predefined and reserved by the language for specific functionalities, making it easier for programmers to write efficient and standard code. Keywords are part of the syntax and convey the compiler how to interpret a piece of code. Since they are reserved, they cannot be redefined or used for any other purpose.
C provides a small set of keywords compared to modern programming languages, ensuring simplicity and performance. Understanding keywords is essential for learning the language and using its features effectively.
Key points about keywords
- Keywords are case-sensitive in C. For example,
if
andIf
are treated differently. - There are 32 standard keywords in C.
- Keywords cannot be used as variable names, function names, or any other identifiers.
- They provide specific instructions to the compiler to perform operations like branching, looping, data type definition, and memory management.
- Some compilers may introduce additional keywords as extensions, but these are non-standard.
Table of Keywords
Keyword | Description |
---|---|
auto |
Declares an automatic variable |
break |
Exits a loop or switch statement |
case |
Defines a branch in a switch statement |
char |
Declares a character variable |
const |
Declares a constant value |
continue |
Skips the current iteration of a loop |
default |
Defines the default branch in a switch |
do |
Starts a do-while loop |
double |
Declares a double-precision floating point |
else |
Provides an alternative branch in an if |
enum |
Defines an enumeration |
extern |
Declares an external variable |
float |
Declares a floating-point variable |
for |
Starts a for loop |
goto |
Transfers control to a labeled statement |
if |
Starts a conditional statement |
int |
Declares an integer variable |
long |
Declares a long integer variable |
register |
Declares a register variable |
return |
Exits from a function |
short |
Declares a short integer variable |
signed |
Declares a signed variable |
sizeof |
Determines the size of a data type |
static |
Declares a static variable |
struct |
Declares a structure |
switch |
Starts a switch statement |
typedef |
Defines a new type name |
union |
Declares a union |
unsigned |
Declares an unsigned variable |
void |
Declares a void type |
volatile |
Declares a variable that can be modified externally |
while |
Starts a while loop |
Keywords in C are indispensable for writing efficient and functional programs. They form the backbone of the language’s syntax and provide instructions to the compiler for various operations. Understanding these reserved words is crucial for any programmer learning C, as it helps in creating structured and standard-compliant code. By mastering the use of keywords, you can unlock the full potential of the C programming language.
Keywords
- typedef
- Defines a new name for an existing data type in C to improve code readability and maintainability.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.