What is an identifier and its rules in C language?

CServer Side ProgrammingProgramming

Identifier is one of the tokens which are used in C programming language. It is a name which is used to identify the variables, constants, functions, arrays, and also user-defined data.

We cannot use keywords as identifiers because keywords are reserved for special use. Once declared, we can use the identifier in later program statements which refers to the associated value.

The special kind of identifier is known as a statement label and it can be used in goto statements.


The rules for naming identifiers are as follows −

  • Identifier names are unique.

  • Cannot use a keyword as identifiers.

  • Identifier has to begin with a letter or underscore (_).

  • It should not contain white space.

  • Special characters are not allowed.

  • Identifiers can consist of only letters, digits, or underscore.

  • Only 31 characters are significant.

  • They are case sensitive.


Following is the C program to identify which terms are called as identifiers

 Live Demo

/* C Program to Count Vowels and Consonants in a String */
#include <stdio.h>
int main(){
   char str[100];
   int i, vowels, consonants;
   i = vowels = consonants = 0;
   printf("\nEnter any String : ");
   while (str[i] != '\0'){
      if(str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u'
      || str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U'){
   printf("\n no of Vowels in the given String = %d", vowels);
   printf("\n no of Consonants in the given String = %d", consonants);
   return 0;


When the above program is executed, it produces the following result −

Enter any String : Tutorials Point
no of Vowels in the given String = 6
no of Consonants in the given String = 9

In the above program the identifiers are −

Str, i, vowels, consonants

Published on 03-Sep-2021 07:16:56