Keyword in C
In C programming, keywords (also known as reserved words) are predefined words with special meanings that are reserved by the language. These words have specific purposes and cannot be used as identifiers (variable names, function names, etc.) in the program.
Keywords in C are used to define the syntax and structure of the language, and they play a crucial role in forming valid statements, control structures, and function declarations. The C language has a fixed set of keywords that are recognized and interpreted by the compiler.
Here are some examples of keywords in C:
auto | double | int | struct | break |
else | long | switch | case | enum |
register | typedef | char | extern | return |
union | const | float | short | unsigned |
continue | for | signed | void | default |
goto | sizeof | volatile | do | if |
static | while |
These keywords have predefined meanings and serve specific purposes in the C language. It is important to note that keywords are case-sensitive, meaning that uppercase and lowercase letters make a difference. Therefore, "if", "If", and "IF" are considered different keywords in C.
Using keywords as variable names or identifiers is not allowed in C. For example, you cannot declare a variable named "int" or use "if" as a function name.
Here's an example illustrating the usage of some C keywords:
#include <stdio.h>
int main() {
int num = 10;
if (num > 5) {
printf("The number is greater than 5.\n");
} else {
printf("The number is less than or equal to 5.\n");
}
return 0;
}
In the example above, "int", "if", and "else" are keywords used to declare an integer variable, define a conditional statement, and specify alternative code blocks respectively.