Variables
Variables
- Definition of variables:
A variable is a name of data that is used to store the value of data. In C programming language a variable is the named memory location where a program can manipulate the data. This location is used to hold the value of the variable. The value of the C variable may get a change in the program as it depends on the type of program. You can think of a variable as being equivalent to its assigned value.
A variable name can be chosen by the programmer in a meaningful way so as to reflect its function or nature in the program.
- Some examples of names are,
sum
average
total
counter_1
class
- Condition/rules for naming variable:-
- A variable name must begin with a letter or underscore.
- Variable are case sensitive. The variable Total is not the same as TOTAL or total.
- ANSI standard recognizes a length of 31 characters.
- White space is not allowed.
- No, any special characters/symbols are allowed other than underscores.
- It should not be a keyword.
- Some example of the valid variable names:
sum sum3 div
delhi sum_3 S_um
mark T_rais Name
-
Some example of the invalid variable name:
Char - keyword is not valid
sum$ - special character is not valid
1323 - starting from number is not valid
avg value - white space is not valid
- Some examples of names are,
sum
- Condition/rules for naming variable:-
- A variable name must begin with a letter or underscore.
- Variable are case sensitive. The variable Total is not the same as TOTAL or total.
- ANSI standard recognizes a length of 31 characters.
- White space is not allowed.
- No, any special characters/symbols are allowed other than underscores.
- It should not be a keyword.
- Some example of the valid variable names:
sum sum3 div
delhi sum_3 S_um
mark T_rais Name
- Some example of the invalid variable name:
Char - keyword is not valid
sum$ - special character is not valid
1323 - starting from number is not valid
avg value - white space is not valid
Comments
Post a Comment