Identifiers in c – an identifier is a string of alphanumeric characters that begins with an alphabetic character or an underscore which are used to represent various programming elements. Example, variables, functions, arrays, structures, unions, etc.
Identifiers are the names given to various program elements such as constants, variables, function names and arrays etc.
Every element in the program has its own distinct name but one cannot select any name unless it conforms to valid name in C language.
Let us study first the rules to define names or identifiers.
Rules for Forming Identifiers
Identifiers are defined according to the following rules:
- It consists of letters and digits.
- The first character must be an alphabet or underscore.
- Both upper and lower cases are allowed. Same text of different case is not equivalent, for example: TEXT is not same as text.
- Except for the special character underscore ( _ ), no other special symbols can be used.
- For example, some valid identifiers are shown below
For example, some invalid identifiers are shown below:
456 First character to be an alphabet.
“Y.” Not allowed.
sheet-no Hyphen allowed.
Same thing Blankspace allowed.