C Variable Names (Identifiers)

C Variable Names (Identifiers) – Complete Guide
In C language, variable names are also called identifiers.
They are used to identify variables, functions, arrays, and other user-defined items in a program.
Choosing correct and meaningful identifiers is important for readability, correctness, and interviews.
What is an Identifier in C?
An identifier is the name given to a variable, function, array, or any other user-defined element.
Here:
age,totalMarks,grade→ identifiers
Rules for Naming Identifiers (Very Important)
C identifiers must follow these rules:
Allowed
Can contain letters (a–z, A–Z)
Can contain digits (0–9)
Can contain underscore
_Must start with a letter or underscore
Not Allowed
Cannot start with a digit
Cannot contain special symbols (
@,#,$,%, etc.)Cannot be a C keyword
Cannot contain spaces
Valid Identifier Examples
- All follow C naming rules
Invalid Identifier Examples
Case Sensitivity in C
C is case-sensitive.
ageandAgeare different identifiers
Keywords Cannot Be Identifiers
C keywords are reserved words.
Examples:
Some common C keywords:
Length of Identifiers
C allows long identifiers
At least 31 characters are significant (compiler dependent)
- Valid, but keep names readable
Naming Conventions (Best Practices)
Although not mandatory, follow these good practices:
Use-meaningful names
Use-lowercase for variables
Use-uppercase for constants
Use-underscore for multi-word names
Identifiers for Different Elements
Variable
Function
Array
Structure
Identifier vs Variable Name
| Term | Meaning |
|---|---|
| Identifier | Name of any user-defined element |
| Variable Name | Identifier that stores a value |
- Every variable name is an identifier, but not every identifier is a variable
Common Mistakes
- Using keywords as names
- Starting with digits
- Using special symbols
- Writing unreadable names
- Confusing case sensitivity
Interview Questions (Must Prepare)
What is an identifier in C?
Rules for naming identifiers
Can identifier start with
_?Is C case-sensitive?
Difference between keyword and identifier
Maximum length of identifier in C
Summary
- Identifiers are names given to program elements
- Must start with letter or
_ Cannot use keywords or special symbols- C is case-sensitive
- Good naming improves readability & maintenance
- Very important for basics, exams & interviews
