In C programming, identifiers are names given to various program elements like variables, functions, arrays, etc. Identifiers make it easier for programmers to understand the code, as they allow referencing different parts of the program by meaningful names.
_
).example
and Example
are considered different identifiers).int
, float
, if
, etc.) cannot be used as identifiers._
).As per the above rules, some examples of the valid and invalid identifiers are:
age, Age, AGE, average_age, __temp, address1, phone_no_personal, _my_name
Average-age, my name, $age, #phone, 1mg, phy+maths
<data_type> identifier_name;
#include <stdio.h>
// Function prototype
void greetUser();
// Global variable
int count = 5;
int main() {
// Local variable
int localValue = 10;
greetUser(); // Function call
printf("Global count: %d\n", count); // Print global variable
printf("Local value: %d\n", localValue); // Print local variable
return 0;
}
// Function definition
void greetUser() {
printf("Hello, user!\n");
}
age
, height
, etc.printData
, calculateSum
, etc.data
, values
, etc.int marks1 = 50, marks2 = 60;
float avg = (float) (marks1 + marks2) / 2;
int average(int marks1, int marks2)
{
return (float) (marks1 + marks2) / 2;
}
struct student
{
int rollno;
char *name;
int m1, m2, m3;
float percent;
};
struct student s1 = {1, "Raju", 50, 60, 70, 60.00};
int
, float
.2data
instead of data2
.#
, @
, &
which are not allowed in identifiers.totalAmount
or calculateAverage
.camelCase
for variables, PascalCase
for function names).Identifiers are fundamental in making the code readable, organized, and understandable for others working on the same code. Remember to follow the rules and best practices for creating effective identifiers in C programs.