Skip to content
Related Articles

Related Articles

Difference between Identifiers and Variables in C
  • Last Updated : 28 Oct, 2020

Perquisites: Identifiers, Variables

Identifiers

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.

Variables

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

IdentifiersVariables
It is a unique name which is given to an entity to distinctly identify it meanwhile the execution of the source-codeA  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 an exaggeration 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.

Ex:          enum geeks_artiles_in {

                                 Jan=1, Feb, Mar, Apr, May, June, July 



                                                }  

Ex:          int geeks_f_geeks ( int gfg_id ) { /* ….

                                                                 code        

                                                           …… */ }

Ex:

short int geeks_id{} , int a{}  , long float b{ } , unsigned int c{ } , char ch , etc  

Want to learn from the best curated videos and practice problems, check out the C Foundation Course for Basic to Advanced C.
My Personal Notes arrow_drop_up
Recommended Articles
Page :