Difference Between Identifier and Variable

Computer ProgrammingProgrammingMiscellaneous

In this post, we will understand the difference between an identifier and a variable.

Identifier

• All of them are not variables.

• They are used to name a variable, a function, a class, a structure, a union.

• It is created to give a unique name to an entity.

• They can consist of alphabets, digits, and underscores.

• There is no punctuation or special symbol, except the underscore.

• It can be upper case or lower case.

• It can start with lower case letter, upper case letter or an underscore.

• It helps locate the name of the entity which is defined along with a keyword.

Example

enum geeks_artiles_in {Jan=1, Feb, Mar, Apr, May, June, July}

Variable

• It is used to give a name to a memory location.

• It holds a value.

• The names of variables are different.

• They help allot a unique name to a specific memory location.

Example

int a = 6;
Published on 24-Mar-2021 14:19:45