Keywords are reserved words defined by the C language. They have predefined meanings and cannot be used as identifiers such as variable or function names.
#include <stdio.h>
int main()
{
int number = 10;
if (number > 0)
{
printf("Positive\n");
}
return 0;
}
Example Output #
Positive
Explanation #
The program uses several C keywords:
int
if
return
Each has a specific language-defined meaning.
For example:
int number = 10;
uses int to specify the type of number.
if (number > 0)
uses if to conditionally execute a statement.
return 0;
uses return to terminate the main() function and provide its return value.
C Keywords #
The following table lists the keywords defined by the C language through C23:
| Keyword | Keyword | Keyword | Keyword |
|---|---|---|---|
alignas |
alignof |
auto |
bool |
break |
case |
char |
const |
constexpr |
continue |
default |
do |
double |
else |
enum |
extern |
false |
float |
for |
goto |
if |
inline |
int |
long |
nullptr |
register |
restrict |
return |
short |
signed |
sizeof |
static |
static_assert |
struct |
switch |
thread_local |
true |
typedef |
typeof |
typeof_unqual |
union |
unsigned |
void |
volatile |
while |
_Alignas |
_Alignof |
_Atomic |
_BitInt |
_Bool |
_Complex |
_Decimal128 |
_Decimal32 |
_Decimal64 |
_Generic |
_Imaginary |
_Noreturn |
_Static_assert |
_Thread_local |
— |
The exact keyword set depends on the C standard being used. Older standards such as C90, C99, C11, and C17 contain fewer keywords than C23.
Keywords cannot be declared as ordinary identifiers:
int return = 10; /* Invalid */
A name such as return_value is valid because it is an identifier, not the keyword return.