Constant
- A constant is a value or identifier whose value is fixed and does not change, in the entire program.
- Constant is similar to a variable but it can hold only a single variable during the execution of program.
- Ex: const double PI = 3.14;
Here,- Const is a identifier
- Double is a data type
- PI is a constant variable name that takes a value of 3.14.
- This value of 3.14 does not change during the entire program.
Variable
- Variable is any characteristic, number, or quantity that can be measured or counted.
- It is also called as data item.
- A Variable is a name or an identifier that can store any values, and those values can be changed at any time during the program.
- For example: int score = 6;
- Here, score is a variable name of integer type that stores the value 6. The value of score can be changed any time during the program.