Loading content...
Loading content...
An identifier is a user-defined name used to identify variables, functions, arrays, structures, and other program elements in C.
In simple terms, identifiers are the names given by programmers to different components of a program.
int age = 25;
void display() {
}Here, age is an identifier.
Here, display is an identifier.
A valid identifier in C must follow these rules:
Can contain letters (A-Z, a-z), digits (0-9), and underscore (_).
Must begin with a letter or underscore.
Cannot start with a digit.
Identifiers are case-sensitive.
Cannot use C keywords as identifiers.
Special characters such as @, #, $, %, - are not allowed.
age
studentName
_count
totalMarks
student11student
user-name
user@name
return
int#include <stdio.h>
int main() {
int marks;
marks = 90;
printf("%d", marks);
return 0;
}90In this example, marks is the identifier.
#include <stdio.h>
int sum(int a, int b) {
return a + b;
}
int main() {
printf("%d", sum(10, 20));
return 0;
}30In this example, sum is the identifier.
Although not mandatory, these conventions improve code readability.
Use camelCase naming.
int studentAge;
int totalMarks;
int employeeCount;Use UPPER_SNAKE_CASE naming.
#define MAX_SIZE 100
#define PI 3.14Use camelCase and meaningful action names.
getName();
calculateSalary();
countFrequency();Use PascalCase naming.
struct Student;
struct Employee;
struct Car;Keywords are reserved words in C and cannot be used as identifiers.
#include <stdio.h>
int main() {
int const = 90;
return 0;
}error: expected identifier or '(' before '=' tokenThe error occurs because const is a C keyword and cannot be used as an identifier.
int
char
float
double
if
else
for
while
switch
case
break
continue
return
const
voidAn identifier is a user-defined name.
Used for variables, functions, arrays, structures, and other program elements.
Must start with a letter or underscore.
Cannot start with a digit.
Cannot be a keyword.
Identifiers are case-sensitive.
Meaningful names make code easier to read and maintain.