Back

Variables and Constants

VARIABLES AND CONSTANTS

A variable is a value which can change overtime. A constant is a value which cannot change overtime.

In real life situations, there are some related data that we need to keep in mind for future reference. Our memory is the storage which remembers what all we see, talk, hear and do. Similarly while solving a problem using programming; we need to store some data for reference in future. For this we use either variables or constants. These are stored in computer’s memory.
As the name suggests, the value of a variable can change. This change can happen during the course of action of solving the problem.

However, the value of a constant remains the same. It does not change during the entire process of problem solving.

Let’s consider an analogy. When we go out to purchase a Book, the price of the book remains the same, whereas the quantity will change as per requirement. Hence here the Book Price is a constant value where as quantity is a variable value.

Subscribe to our newsletter for courses and tutorial updates.