Identifiers in C (original) (raw)

Last Updated : 7 Apr, 2026

In C programming, identifiers are the names used to identify variables, functions, arrays, structures, or any other user-defined items. It is a name that uniquely identifies a program element and can be used to refer to it later in the program. **Example:

C `

// Creating a variable int val = 10;

// Creating a function void func() {}

`

In the above code snippet, "**val" and "**func" are identifiers.

Rules for Naming Identifiers in C

A programmer must follow a set of rules to create an identifier in C:

The below image and table show some **valid and **invalid identifiers in C language.

identifiersInC

Example

The following code examples demonstrate the creation and usage of identifiers in C:

Creating an Identifier for a Variable

C `

#include <stdio.h>

int main() {

  // Creating an integer variable and
  // assign it the identifier 'var'
  int var;

  // Assigning value to the variable
  // using assigned name
  var = 10;

  // Referring to same variable using 
  // assigned name
  printf("%d", var);
  
  return 0;

}

`

C**reating an Identifier for a Function

C++ `

#include <stdio.h>

// Function declaration which contains user // defined identifier as it name int sum(int a, int b) { return a + b; }

int main() {

// Calling the function using its name
printf("%d", sum(10, 20));
return 0;

}

`

Naming Conventions

In C programming, naming conventions are not strict rules but are commonly followed suggestions by the programming community for identifiers to improve readability and understanding of code. Below are some conventions that are commonly used:

For Variables:

For Functions:

For Structures:

Read about Differences between keywords and identifiers in C.

What happens if we use a keyword as an Identifier in C?

In the below code, we have used const as an identifier which is a keyword in C. This will result in an error in the output.

C++ `

#include <stdio.h>

int main() {

// used keyword as an identifier
int const = 90;

return 0;

}

`

**Output

​./Solution.c: In function 'main':
./Solution.c:5:14: error: expected identifier or '(' before '=' token
int const = 90;
^