Variables and rule for constructing variables in C
VARIABLES
- A variable is a data name that may be used to store a data value and which can be changed during the execution of the program.
- A variable may take different values at different times during execution.
- A variable name can be chosen by the programmer in a meaningful way so as to reflect its function or nature in the program. Example: Average, sum, Total, Answer, number etc.
Rules for constructing variable in C
The following are the rules for variable naming
- They must begin with a letter. Some system permits underscore as the first character.
- ANSI standard recognizes a length Of 31 characters. However, the length should not be normally more than eight characters, since only the first eight characters are treated as significant by many compilers.
- Uppercase and lowercase are significant. That is Total is not the same as total or TOTAL.
- It should not be a keyword(like int, float).
- White space is not allowed.
![]() |
Examples of variable names |
Video tutorial:
No comments:
For Query and doubts!