The Wayback Machine - https://web.archive.org/web/20240629174600/https://www.geeksforgeeks.org/difference-between-identifiers-and-variables-in-c/
Open In App

Difference between Identifiers and Variables in C

Last Updated : 28 Oct, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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

Identifiers 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 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  



Similar Reads

Difference between Static variables and Register variables in C
static variables Static variables have a property of preserving their value even after they are out of their scope! Hence, static variables preserve their previous value in their previous scope and are not initialized again in the new scope. Syntax: static data_type var_name = var_value; register variables Registers are faster than memory to access
2 min read
C Identifiers
In C programming language, identifiers are the building blocks of a program. Identifiers are unique names that are assigned to variables, structs, functions, and other entities. They are used to uniquely identify the entity within the program. In the below example "section" is an identifier assigned to the string type value. char section = 'A';For
3 min read
Difference Between Constants and Variables in C
The constants and variables in C are both used to store data. So it is essential to know the difference between the variables and constants in C so that we can decide which one to use based on the situation. In this article, we will discuss the basic difference between a constant and a variable in C language. Variables in C A variable in simple ter
3 min read
Difference between static and non-static variables in Java
There are three types of variables in Java: Local VariablesInstance VariablesStatic Variables The Local variables and Instance variables are together called Non-Static variables. Hence it can also be said that the Java variables can be divided into 2 categories: Static Variables: When a variable is declared as static, then a single copy of the vari
4 min read
What are the differences between PHP constants and variables ?
PHP Constants: PHP Constants are the identifiers that remain the same. Usually, it does not change during the execution of the script. They are case-sensitive. By default, constant identifiers are always uppercase. Usually, a Constant name starts with an underscore or a letter which is followed by a number of letters and numbers. They are no need t
2 min read
Differences between undeclared and undefined variables in JavaScript
This article will give the idea of undefined & undeclared variables in Javascript, also discussing their differences & understanding the implementation through the examples. In a programming language, the variables are used to store some kind of information & every programming language contains different kinds of procedures and techniqu
4 min read
Problem Solving on Storage Classes and Scoping of Variables
Storage class of variables includes the scope, visibility and life-time which help to trace the existence of a particular variable during the runtime of a program. There exist four types of storage classes in C: auto, register, static and extern. Auto and Register Storage Classes - The scope of variable declared using auto or register storage class
8 min read
Initialization of global and static variables in C
Predict the output of following C programs. // PROGRAM 1 #include <stdio.h> #include <stdlib.h> int main(void) { static int *p = (int*)malloc(sizeof(p)); *p = 10; printf("%d", *p); } // PROGRAM 2 #include <stdio.h> #include <stdlib.h> int *p = (int*)malloc(sizeof(p)); int main(void) { *p = 10; printf("%d"
1 min read
How will you show memory representation of C variables?
Write a C program to show memory representation of C variables like int, float, pointer, etc. Algorithm: Get the address and size of the variable. Typecast the address to char pointer. Now loop for size of the variable and print the value at the typecasted pointer.Program: C/C++ Code #include <stdio.h> typedef unsigned char *byte_poin
1 min read
How are variables scoped in C - Static or Dynamic?
In C, variables are always statically (or lexically) scoped i.e., binding of a variable can be determined by program text and is independent of the run-time function call stack. For example, output for the below program is 0, i.e., the value returned by f() is not dependent on who is calling it. f() always returns the value of the global variable x
1 min read
three90RightbarBannerImg