Keywords and Identifiers are very confusing for few. Sometimes if you've tried adding a variable name like, "int default" . After compiling the problem, you'll face errors. The reason being the usage of a reserved word, in the above example, "default". Still foggy?

Keywords and Identifiers in C

No more puns; lets follow up whats coming up.

Keywords and Identifiers

1. Keywords and Identifiers

Keywords are special terms reserved for a special purpose in a language, which cannot be used as variable names. Both Keywords and Identifiers are reserved by the language for special use. All keyword must be written in lower case alphabets. There are 32 keywords in C language. Here are few keywords given below.

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

Identifier on the other hand is a fancy term used to mean "name". In C, identifiers are used to refer a number of things: like referring them as name of variables and functions.

2. Character Sets of C

The characters used in C language are broadly classified as follows:


Upper Case Letters: A B C ... Z

Lower Case Letters: a b c ... z

C accepts both upper as well as lower case of alphabets.


0 1 2 3 4 5 6 7 8 9

Special Characters

, < > . _ ( ) ; $ : % [ ] # ? ' & { } " ^ ! * / | - \ ~ +

Blank Space Characters, New Line, Horizontal tab, Carriage Return, etc.

Rules for Writing Keywords

Consider an example:

int side;

Here, int is a keyword which indicates side is a variable of data type Integer.

So here comes first rule:

You cannot use any valid keyword as an identifier.

Since these are case sensitive so, be careful while writing them, i.e. write them in lower case letters.

Rules for writing Identifiers:

A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
The first letter of an identifier should be either a letter or an underscore. However, it is discouraged to start an identifier name with an underscore.
There is no rule on length of an identifier. However, the first 31 characters of identifiers are discriminated by the compiler.

I hope this article was helpful to understand Keywords and Identifiers in C! Comment below, if you've got any question. Head back soon for another interesting article on C Programming.