C Identifiers

 An identifier is a collection of alphanumeric characters that begins either with an alphabetical character or an underscore, which are used to represent various programming elements such as variables, functions, arrays, structures, unions, labels, etc. 

There are 52 alphabetical characters (uppercase and lowercase), underscore character, and ten numerical digits (0-9) that represent the identifiers.

Rules for Creating Identifiers
  • The first character of an identifier should be either an alphabet or an underscore, and then it can be followed by any of the character, digit, or underscore.
  • It should not begin with any numerical digit.
  • In identifiers, both uppercase and lowercase letters are distinct. Therefore, we can say that identifiers are case sensitive.
  • Commas or blank spaces cannot be specified within an identifier.
  • Keywords cannot be represented as an identifier.
  • The length of the identifiers should not be more than 31 characters.
  • Identifiers should be written in such a way that it is meaningful, short, and easy to read.
Example

int marks;
char studentName[30];

Here, marks and studentName are identifiers.

 

Differences between Keyword and Identifier

 

Keyword Identifier
Keyword is a pre-defined word. The identifier is a user-defined word
It must be written in a lowercase letter. It can be written in both lowercase and uppercase letters.
Its meaning is pre-defined in the c compiler. Its meaning is not defined in the c compiler.
It is a combination of alphabetical characters. It is a combination of alphanumeric characters.
It does not contain the underscore character. It can contain the underscore character.





No comments:

Post a Comment