What is a variable in programming and rules to define a variable??
Answers
Answered by
1
Hi friend,
A variable is a name of memory location. It is used to store data. Its value can be changed and it can be reused many times.
TO declare variable as:
datatype variablename;
Ex: int a;
To initialize value as :
datatype variablename =value;
Ex: int a=100;
Rules for defining variables
A variable can have alphabets, digits and underscore.
A variable name can start with alphabet and underscore only. It can't start with digit.
No white space is allowed within variable name.
A variable name must not be any reserved word or keyword e.g. int, float etc.
Hope this helps.......
A variable is a name of memory location. It is used to store data. Its value can be changed and it can be reused many times.
TO declare variable as:
datatype variablename;
Ex: int a;
To initialize value as :
datatype variablename =value;
Ex: int a=100;
Rules for defining variables
A variable can have alphabets, digits and underscore.
A variable name can start with alphabet and underscore only. It can't start with digit.
No white space is allowed within variable name.
A variable name must not be any reserved word or keyword e.g. int, float etc.
Hope this helps.......
Answered by
3
=>>
Variable - Variable is the name of memory space in computer. In other words we can say that variables are data types that can holds any value. We can change the Value of the variable.
As- int a,b; (here 'int' is a data type and 'a' and 'b' are variables.)
Rules to define a variable -
- A variable name is the combination of Alphabet , numbers and underscore.
- The first letter of the variable must be an alphabet.
- No comma and space are allowed in variable name.
- No special symbol other than underscore is allowed.
- Keywords are not used as a variable name.
Similar questions