Identifiers are used for the naming of variables, functions, and arrays. It is a string of alphanumeric characters that begins with an alphabet, or an underscore( _ ) that are used for variables, functions, arrays, structures, unions, and so on. It is also known as the user-defined word. Identifier names must differ in spelling and case from any keywords. We cannot use keywords as identifiers; they are reserved for special use. Once an identifier is declared, we can use the identifier anywhere in the program to refer to the associated value.
A variable is a name that points to a memory location. It is the basic unit of storage in a program. The value of a variable can be changed during program execution. All the operations are done on the variable effects that memory location. In C, all the variables must be declared before use and in C++ we can declare anywhere in the program at our convenience.
Difference Between Identifiers and Variables
|It is a unique name which is given to an entity to distinctly identify it meanwhile the execution of the source-code||A Variable is a name that is assigned to a memory location, which is used to contain the corresponding value in it. Variables are only the sort of identifiers.|
|It strictly prohibited to have the same of two or more identifiers. It Ex’s: are Structure name, Function name, Class, Enumerator name, Union, etc.||It wouldn’t be exaggregation to say that all variables are identifiers whereas vice-versa isn’t true. The values can be Real, Char, String, Int, Float, Double, Unsigned, etc.|
|An identifier name shouldn’t resemble with the keywords because keywords are predefined. Double, Continue, float, else, etc can’t be used as identifiers in a program.||The value that is stored in memory block can be modified meanwhile the program executed. Similarly, as identifiers, two or more variables also can’t have the same name in a program.|
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference between Static variables and Register variables in C
- Difference between static and non-static variables in Java
- Variables in C++
- Variables and Keywords in C
- Static Variables in C
- Can Global Variables be dangerous ?
- Implicit initialization of variables with 0 or 1 in C
- Operations on struct variables in C
- Initialization of static variables in C
- Constants vs Variables in C language
- Why do we need reference variables if we have pointers
- Initialization of global and static variables in C
- C Program to print environment variables
- Initialization of variables sized arrays in C
- How will you show memory representation of C variables?
- How are variables scoped in C - Static or Dynamic?
- What are the default values of static variables in C?
- Swap two variables in one line in C/C++, Python, PHP and Java
- Linking Files having same variables with different data types in C
- Problem Solving on Storage Classes and Scoping of Variables
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.