What are Constant and Variable
Definition of constant and variable.
Constant: An entity that does not change.
Variable: An entity that may change.
Let see example of both constant and variable.
In C language, We declare an integer variable like this
int n; //declaration of n
Now initialize variable n
n = 45; // initialization of n
The value stored in n is 45. Now we can change the value that is stored in n.
n = 32;
We saw that n can take different value while we can not change value of 45. (its value is 45).
So here n is a variable and 45, 32 are constants.
Constant: An entity that does not change.
Variable: An entity that may change.
Let see example of both constant and variable.
In C language, We declare an integer variable like this
int n; //declaration of n
Now initialize variable n
n = 45; // initialization of n
The value stored in n is 45. Now we can change the value that is stored in n.
n = 32;
We saw that n can take different value while we can not change value of 45. (its value is 45).
So here n is a variable and 45, 32 are constants.