Identifier in C

Identifier in C


What is Identifier ?

An identifier is a collection of alphanumeric characters that are used to represent variables, functions, arrays, structures, unions, labels and so on.

How to declare an Identifier ?

Syntax : 
datatype IdentifierName;
Example :
#include <stdio.h>
int main()
{
  int she;
  float anik;
  return 0;
}

//here, int, float are datatypes.
// she and anik are identifiers.

Types of Identifier :

C defines two types of Identifiers.

1. Internal Identifier : 

The identifier which is not used in an external linkage, is known as an Internal Identifier. These internal Identifier can be the local variables.

2. External Identifier : 

Those identifiers which are used in an external linkage, are known as an External Identifier. These internal Identifier can be the global variables, function names.

Rules for declaration of Identifiers :

1. First character must be started with a letter or an underline not with a digit. The remaining are of an alphabet, any numeric digit or the underscore character. Including both uppercase and lowercase there are 53 characters, to repressent Identifiers. The underscore( _ ) character is considered as a letter in identifiers. So There are total 63 alphanumeric characters, which are 53 alphabetic characters and 10 digits (i.e., 0-9).
2. Identifier names must be unique.
3. Blankspaces and commas are not allowed within an Identifier.
4. Keywords can't be used as identifiers.
5. There is no rule on how long an identifier can be. However, only the first 31 characters are significant.
6. Identifiers are case sensitive.

Example  :
#include <stdio.h>
int main()
{
  int Anik=117,anik=56,aniK=211;
  printf("The value of the identifiers are : %d\n%d\n%d\n",Anik,anik,aniK);
  return 0;
}
Output :


7. Once an identifier is declared under any datatype it can't be redeclared even in its current datatype itself. It will cause error in the output.


#include <stdio.h>
int main()
{
  int Anik=117,anik=56;
  int anik=211;
  printf("The value of the identifiers are : %d\n%d\n%d\n",Anik,anik,anik);
  return 0;
}

//The output will cause an error as anik is redeclared.
Output :