C Programming Identifiers and Keywords

Keywords and Identifiers in C programming language are the building blocks of any C program.

Identifiers in C

In C programming language, the name of variables, functions, labels and user-defined entities are called Identifiers. Each element of a C program are given an identifier. A C identifier can be of any length, there is no limit on the length of the identifiers in C.
For Example

  • int Interest;
  • int getSimpleInterest(int amount);

Interest is an identifier for a variable of integer data type and getSimpleInterest is an identifier for a function.

C identifiers are case sensitive, which means ‘value’ and ‘Value’ will be treated as two different identifiers.

Rules for Writing Identifiers

  • An identifier can be composed of alphabets, digits, and underscore only.
  • The first character of an identifier must be either an alphabet or underscore.
  • Identifier name is case sensitive. Home and home is recognised as two separate identifiers.
  • Any special characters other than alphabets, digits, and underscore (such as :, . ,blank space, / are not allowed).
  • An identifier cannot be same as a C keyword.

Examples of Valid and Invalid Identifiers

Valid Identifiers Invalid Identifiers
program 1program
Program Progr/am
_program prog ram
prog_ram pro,,,gram

Keywords in C

C keywords are the reserved words which are pre-defined in C language. We cannot use keywords as an identifier for variable or function. Each keyword has a pre-defined meaning for C compiler.

  • Trying to use a keyword as an identifier will generate a compilation error.
  • All keywords are in lower case letters.

There are 32 keywords defined in C programming language.

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

We will cover above mentioned keywords in upcoming tutorials.