Skip to main content

C Identifier

Identifiers is a name of functions, variables and user defined data type variable. that are used to instruct and perform some operations in during program execution. that is user defined word.

C identifiers

There is three situation to define identifiers

Case 1 : Define variables

Name of variable is an identifier in C, We provide a custom name of variables when its declare.

//data_type name_of_variable;
int age;//age is identifier
char status;//status is an identifier
float *salary;//salary is an identifier

Case 2 : define functions

void info(){//info is identifier
void getSalary(int id){//getSalary and id is identifier
//body of function

Case 3: user define data type variables

class Student{ //Student is identifier
  //data member and function
struct Book{ //Book is an identifier
  //data item

For Example

  Example of identifiers 
/*Header file*/
#include <stdio.h>

//get_salary and id is identifiers
float get_salary(int id){
int main(){
  //Book is identifiers
  struct Book{
    int pages;
    float weight;
    double price;

  // counter is identifiers
  int cunter=10;
  //salary is identifiers
  float salary=100;

  return 0;

Rules of identifiers

1) Identifier name should not be same as keyword.

2) Identifier are contains char, number and underscores.

3) First character of an identifier is start with alphabets(a to z or A to Z) and underscore (_).

4) Digit are not allowed to start variable name.

5) There are no rule to define the length of identifier. but there are only single words not use space char to separate identifiers.

6) Identifiers are case sensitive. example.

  Case sensitive
/*Header file*/
#include <stdio.h>
int main(){
  /*Entry point of program*/

  /*Variables and identifiers*/
  int num=10,Num=20,nuM=30,NUM=40;
  printf("%d  %d  %d  %d",num,Num,nuM,NUM);
  return 0;


10 20  30  40
case sensitive example
  Example of valid identifires
#include <stdio.h>

int main(){
  int __=1; //__ are valid
  int _=2;// _ valid valid
  int num=3; // num is valid
  int int_1=4; //int_1 is valid
  char c='a';//valid
  char C='b'; //case sensitive.( c,C);
  char _char_var='c';
  float floatVar=1.0f; //camel case are valid

  printf("__  : %d\n",__);
  printf("_   : %d\n",_);
  printf("num : %d\n",num);
  printf("int_1 : %d\n",int_1);
  printf("c : %c\n",c);
  printf("C : %c\n",C);
  printf("_char_var: %c\n",_char_var);
  printf("floatVar : %f\n",floatVar);


__  : 1
_   : 2
num : 3
int_1 : 4
c : a
C : b
_char_var: c
floatVar : 1.000000

Tips for Good Programming Practice

1) Provide a meaningful name of identifiers.

float salary;
int age;
char status;
char employee_list[10];
int *auxiliary_ptr;

In form of function

int account_list(int employee){}
float check_balance(int employee_id){}
int add_items(int size, int values){}

2) Try to given length of variable less than 32 char. because some of c compiler cannot differentiate in variable. when the length of variable is more than 32 char.

3) function name and variable name should not same. otherwise compiler produce error. look at this example.

In this program function name and variable name are same. 
then gcc compiler produce error.
#include <stdio.h>
int sum(int a,int b){
  return a+b;
int main(){
  int sum=sum(1,2);
error: called object ‘sum’ is not a function or function pointer. 

Note that if we are use function pointer then this will valid. but in simple case produce an error.


Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.

New Comment