- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is an identifier in C language?
An identifier is used for any variable, function, data definition, labels in your program etc.
Before starting any language, you must at least know how you name an identifier.
In C language, an identifier is a combination of alphanumeric characters, i.e. first begin with a letter of the alphabet or an underline, and the remaining are letter of an alphabet, any numeric digit, or the underline.
Rules for naming identifiers
The rules that must be followed while naming the identifiers are as follows −
The case of alphabetic characters is significant. For example, using "TUTORIAL" for a variable is not the same as using "tutorial" and neither of them is the same as using "TutoRial for a variable. All three refer to different variables.
There is no rule on how long an identifier can be. We can run into problems in some compilers, if an identifier is longer than 31 characters. This is different for the different compilers.
A valid identifier can have letters (both uppercase and lowercase letters), digits and underscores.
The first letter of an identifier should be either a letter or an underscore.
You cannot use keywords like int, while etc. as identifiers.
Identifiers must be unique
For example,
int student; float marks;
Here, student and marks are identifiers.
We have to remember that the identifier names must be different from keywords. We cannot use int as an identifier, because int is a keyword.
Consider another example for identifier.
int var1, var2; float Avg; function sum();
Here,
- int, float, function are all keywords.
- var1, var2, Sum, Avg, are the identifiers.
Keywords are used along with identifiers to define them. Keywords explain the functionality of the identifiers to the compiler.
- Related Articles
- What is an identifier and its rules in C language?
- What is an anagram in C language?
- What is an inline function in C language?
- What are the rules about using an underscore in a C++ identifier?
- What is an extern storage class in C language?
- What is an array of structures in C language?
- What is an algorithm and flowchart in C language?
- What is an auto storage class in C language?
- __func__ identifier in C
- What is out of bounds index in an array - C language?
- Predefined Identifier __func__ in C
- What is a Virtual Circuit Identifier (VCID)?
- What is malloc in C language?
- What is Calloc in C language?
- What is Realloc in C language?
