In any programming language, we have to write a lot of programs and do a lot of calculations. The result of these calculations is stored in any memory location. The memory location can be identified by the computer by its memory location address like- 55606, 55404, 55505, etc. Now Suppose, if a programmer wants to store the data at the memory location a lot of times when he writes the program. Then how difficult to remember the memory location by its address (numbers).
Variables
So, Variables are the name given by the programmer to a memory location to store data on it. Youcan store any type of data on the memory location.
OR
A Variable is an Entity given by the memory location where the data of your program are stored.
Ex:-
Explanation:- On the above image, suppose this is cells of the memory locations. These cells have different addresses. Here we stored a data 52 in a memory location and give it name A. and also store 25 on the other memory location and give it the name Johnny.
So, “A” is the name of the variable where the data 52 has been stored.
And “John” is the name of the variable where 25 has been stored.
Before Creating a Variable name of your memory location there is some rule to construct variable names. Let's check it
Rules for Constructing a Variable Names
A variable name can be constructed by a combination of 1-31 alphabets, digits, and underscore. Some compilers allow variable names up to 257 characters. But do not create unnecessary long variables. Because when you use it on your program you need to type long characters or words again and again.
- The First Character of your variable must be an alphabet or underscore.
- No comma or space is allowed on the variable names.
- No Special symbols are allowed on the variable names. Except for underscore ( _ )
Example of Variable Names:-
- var_a
- var_b10
- int_x
- int_x_123456 etc
You May Also Like
0 comments:
Post a Comment