Identifiers and Keywords in C Language

As we have learned in earlier that tokens are the smallest individual unit of a C program. It is classified into identifiers, keywords, constants, string literals, operators, special symbols.

Identifiers

Identifiers are the name that is used to identify a variables, functions, constants and the user defined items.

*) The identifier can start with a letter between 'A' to 'Z', 'a' to 'z' and underscore('_').

*) No space and special symbols are allowed between the identifier.

*) The identifier cannot be a keyword.

*) The identifiers are case sensitive. Example the variables 'age' and 'Age' are considered as two different identifiers.

Example for valid identifiers

int age;
int age1;

The age and age1 are valid identifiers.

Example for invalid identifier

int 1age;
int #age;

The 1age and #age are not valid identifiers, since it does not follow the above rules.

Keywords

The keywords are the reserved words in C language. C language contains keywords which are described in C compiler. So these keywords cannot be used as the variable name.

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

If we try to create a variable with any of the above keywords, it will throw an error.


Most Read