Key Differences between Identifier and Variable
- Both an identifier and a variable are the names allotted by users to a particular entity in a program. The identifier is only used to identify an entity uniquely in a program at the time of execution whereas, a variable is a name given to a memory location, that is used to hold a value.
- Variable is only a kind of identifier, other kinds of identifiers are function names, class names, structure names, etc. So it can be said that all variables are identifiers whereas, vice versa is not true.
As identifier and variable names are user-defined names, it should be taken care that no two identifiers or no two variable names in a program should be the same. It will create a problem of ambiguity in a program.