Skip to main content

Keywords and Identifiers in C Programming

Keywords

Keywords are predefined words that have a specific meaning and purpose. These words cannot be used as variable names, function names, or any other identifier names.

Below is the list of keywords in C:

KeywordDescriptionKeywordDescription
autoautomatic storage durationbreakexit a loop or switch
casespecify a case in a switchcharcharacter type
constconstant valuecontinueskip to the next iteration of a loop
defaultdefault case in a switchdoexecute a loop
doubledouble precision floating pointelseconditional execution
enumenumeration typeexternexternal variable or function
floatsingle precision floating pointforexecute a loop
gotojump to a labeled statementifconditional execution
intinteger typelonglong integer type
registerregister storage classreturnreturn from a function
shortshort integer typesignedsigned integer type
sizeofevaluate the size of a type or variablestaticstatic storage duration
structstructure typeswitchmultiple selection
typedefdefine a new type nameunionunion type
unsignedunsigned integer typevoidvoid type
volatilevolatile typewhileexecute a loop

Identifiers

An identifier is a name used to identify a variable, function, or any other user-defined item. An identifier is a sequence of letters, digits, and underscores, and it must begin with a letter or an underscore.

Rules for defining identifiers

  • An identifier must start with a letter (a to z or A to Z) or an underscore (_).

  • After the first character, an identifier can contain any combination of letters, digits (0 to 9), and underscores.

  • An identifier cannot be a keyword or a reserved identifier.

  • There is no limit to the length of an identifier, but most compilers have a maximum limit of around 31 characters.

  • An identifier can only contain ASCII characters.

Following are valid identifiers in C:

x
count
_temp
sum_of_numbers

The following are not valid identifiers in C because they do not start with a letter or an underscore:

1x (starts with a digit)
@count (starts with a special character)
temp! (ends with a special character)
tip

It is a good programming practice to choose descriptive and meaningful names for identifiers to make the code easy to understand and maintain.