This content originally appeared on DEV Community and was authored by kiran v
Every single thing (file, data, etc.) we save on computer get stored in computer memory. But actual problem starts when we want that particular data or we want to access it, so as to identify that particular location in computer memory which holds the data we want, we need to give a distinct name to that location so that we can access that data any time by using the location name given.
For e.g. shopkeeper keeps food items in different containers in his shop and stick a paper, which has name of particular food item written on that paper, on that container. You might have seen this many times.
In this example container is a storage area and it can be of any size i.e. small, large. And food items like rice, wheat, etc. can be stored in that container (storage area).
Every container has a sticky paper on it which tells particular food item inside it. With respect to computer analogy, here you can consider the food items as data/value, container as a storage area/memory location.
Above scenario applies to the term “Variable”.
Definition:
Variable is referred as a location in memory in programming languages.
Illustration:
Variable is a location in memory
Value 10 is stored in the memory location and name b is given to that location.
We can store different values in a same variable.
E.g. if we have stored some value in b say 10, then it is possible that we can assign different value to variable b say value 20. So now previous value inside in variable b will be overwritten and it will hold a new value i.e. 20.
Variable can hold only one value at a time.
This content originally appeared on DEV Community and was authored by kiran v
kiran v | Sciencx (2024-09-19T16:43:04+00:00) What is variable in programming. Retrieved from https://www.scien.cx/2024/09/19/what-is-variable-in-programming/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.