What do you mean by variable ? Explain the scope of variables.
Answers
Answered by
3
Answer:
A variable is a named memory location which holds a particular value .
The scope of variables is defined as the place in the program where the variable is valid .
Explanation:
Suppose take the example of :
int x = 5 ;
Here x is a variable which holds the value of 5 .
int is the datatype of x .
Another example is int a = 1 ;
Here a is the variable .
(=) is the assignment operator .
The value of a is assigned 1 .
Scope of a variable can be identified by the separators .
The variable is only valid within the curly braces in which it is declared .
A class variable is valid within the class .
Similar questions