• Home
  • C language keywords and identifier

C language keywords and identifier

In C, keywords are reserved words that have special meanings in the language and cannot be used as identifiers. Some common keywords in C include:

  • auto
  • break
  • case
  • char
  • const
  • continue
  • default
  • do
  • double
  • else
  • enum
  • extern
  • float
  • for
  • goto
  • if
  • int
  • long
  • register
  • return
  • short
  • signed
  • sizeof
  • static
  • struct
  • switch
  • typedef
  • union
  • unsigned
  • void
  • volatile
  • while

Identifiers are used to name variables, functions, and other elements in a C program. They can contain letters, digits, and underscores and must start with a letter or an underscore. However, they cannot contain spaces or special characters, and they are case-sensitive.

For example, the following are valid identifiers in C:

  • myVariable
  • _private
  • age1

The following are not valid identifiers in C:

  • 1age (starts with a digit)
  • my-variable (contains a hyphen)
  • while (a keyword)

It is important to choose descriptive and meaningful names for identifiers to make your code easier to read and understand. It is also important to follow the syntax rules for identifiers to ensure that your code is correct and can be compiled without errors.