Variable
A variable is data name that may be used to store a data value. Other word, variable is element of high level language which is work for data in program.
When we write a program, we use different kind of data. When use these data, it is must be store in memory and variable define the memory address of data.
As like, we write the program for add two number. We know that computer take instruction one by one and then execute these instruction one by one. So, for these addition program, first, Computer take one number from the user the second and store in the memory. After input two numbers, next instruction is adding these two numbers and the result is storing in the memory. All this work computer do following our instruction. If we write this program by machine language, we should must be know the memory address where these number is stored. But is C, it is not necessary to knowing the memory address. In C, we are not use memory address for storing data, just we use the imaginary name for the memory address where we store the data. So we can say, variable is a name of memory area for some bytes.
As example :
a = 5;
b = 10;
c = a+b;
a, b and c is variable and it is not necessary to knowing the memory address where we store 5 or 10. In high level language, it is done by the compiler and we just use a, b and c.
So we know that variable is name of memory address for some bytes. How many bytes are use for use for variable, it is depend what type of data we used (we discuss later about data type).
Some Condition for Variable:
Variable names may consist of letters, digits and the underscore( _ ) character, subject to the following conditions :
· They must begin with a letter. Some systems permit underscore as the first character.
· ANSI standard recognizes a length of 31 characters. However, length should not be normally more than eight characters, since only the first character are treated as significant by many compilers.
· Uppercase and lowercase are significant. That is, the variable Total is not same as total or TOTAL.
· It should not be a keyword. That is, int is not variable, it is a keyword.
· White space is not allowed. Like, total amount is not valid, total_ amount is valid.
Written by "Shojib"
No comments:
Post a Comment