Chapter 2
Chapter 2
Short Questions
vii. Which of the following are valid C variables? Give the reason if not a
valid variable.
area, 5x, Sum, net pay, float, _age, else, case, size22,
my_weight
Area reserved word
Net pay space cannot be included in a variable name.
Float reserved word
Case reserved word
Else reserved word
viii. What are reserved words? Why they should not be used as
variable names?
Reserved words are part of programming language and have special
purpose in computer program.
Reserved words have predefined use so they cannot be used as
variable or any other purpose.
Extensive Questions
Loader:
It is the responsibility of the loader to take the executable module to the
main memory. It allocates the addresses to an executable module in main memory.
Q6. What are the rules for specifying a variable name in C language?
1. A variable begins with a letter or underscore ( _ ) and may consists of letters,
underscores and/or digits.
2. The underscore may be used to improve readability of the variable name. For
example, over_time.
3. There is no restriction on the length of a variable name. However, only the
first 31 characters of a variable are significant. This means that if two
variables have the same first 31 characters they are considered to be the
same variables.
4. Both upper and lower case letters are allowed in naming variable. An upper
case letter is considered different from a lower case letter. For example, the
variable AVG is different from Avg or avg.
5. Special characters cannot be used as variable names. e.g. #, ?, @.
6. Reserved words of C language such as int, case, if, etc., cannot be used as
variable names.
7. There must be no embedded blank in the name of variable. For example
ma ss is not correct.