Skip to main content

Identifier in C

An identifier is the name used to identify variables, functions, arrays, structures, and other user-defined entities in a C program. Think of a contact list on your phone — the contact name is the identifier, and the phone number is the value stored at that name. Similarly, an identifier gives a name to a memory location.

Rules for Identifiers

  • Can contain letters (A–Z, a–z), digits (0–9), and underscore (_)
  • Must begin with a letter or underscore — not a digit
  • Cannot be a C keyword (e.g. int, for, while)
  • Are case-sensitivetotal, Total, and TOTAL are three different identifiers
  • No special characters allowed (@, $, %, #, etc.)
  • No spaces allowed in an identifier name

Valid vs Invalid Identifiers

IdentifierValid?Reason
age✅ ValidLetters only
_salary✅ ValidStarts with _
num1✅ ValidLetter then digit
1num❌ InvalidStarts with a digit
int❌ InvalidReserved keyword
my var❌ InvalidContains a space
@value❌ InvalidSpecial character

Example

int age = 25;
float salary = 50000.50;
char grade = 'A';
Here, age, salary, and grade are identifiers — each names a memory location that stores its respective value.

Key Point

Identifiers are case-sensitive in C. This means:
int total = 10;
int Total = 20;
int TOTAL = 30;
// All three are different variables!