C - Identifiers, Rules for Naming Identifiers

Identifiers are the programmer defined elements like the name of variables, functions arrays, structures etc, They are the fundamental requirement of any language. These are token which is composed of a sequence of letters, digits, and underscore ( _ ). Every language has its own rules for naming identifiers. Identifiers are used to give unique names to different objects in the program.

Identifiers

Identifiers are the programmer defined elements like the name of variables, functions arrays, structures etc, They are the fundamental requirement of any language.

These are token which is composed of a sequence of letters, digits, and underscore ( _ ). Every language has its own rules for naming identifiers. Identifiers are used to give unique names to different objects in the program.

Rules For Naming Identifiers In C

  • An identifier is any combination of alphabets, digits or underscore. 
  • The first character in the identifier name must be an alphabet and not a digit but after that, any digit may follow. 
  • No blank (white space) are allowed within an identifier. 
  • No special symbols other than underscore(as in stn_name) can be used in an identifier. 
  • A maximum length of an identifier is compiler dependent. Originally it was 8 characters. ANSI C permits 31 characters in identifiers. 
  • Upper case and lower case letters are distinct. 
  • A keyword cannot be used as an identifier. 
  • Identifier name should be unique. 
  • The Same Identifier cannot be used again to give the name to another object.

C Identifier Example

Following are some possible examples of identifiers to represent length of box; 
LengthOfBox
Lenght_of_box
length2
LenGth
lb
l

You May Also Like...