Variables in ‘C’ and Identifiers in ‘C’
Variables names are used to store a data value. A variable may take different value during program execution. A variable is defined by the user for eg: - marks, total, average, etc.
Rules to construct a variable
Every variable must begin with an alphabet
It may consist of alphabets or digits or the special symbols underscore _ but no other special symbol is allowed in it.
A variable can be maximum 31 character long but many computers recognize only first 8 characters and ignore the remaining characters
Variable can be written in upper case as well as lower case but note that they are not interchangeable. Hence ‘C’ is called as CASE SENSITIVE LANGUAGE for eg: - TOTAL, total, toTal, Total are taken as 4 different variables.
A Variable should not be a keyword.
Note that variables are also called as identifiers
Rules to construct a variable
Every variable must begin with an alphabet
It may consist of alphabets or digits or the special symbols underscore _ but no other special symbol is allowed in it.
A variable can be maximum 31 character long but many computers recognize only first 8 characters and ignore the remaining characters
Variable can be written in upper case as well as lower case but note that they are not interchangeable. Hence ‘C’ is called as CASE SENSITIVE LANGUAGE for eg: - TOTAL, total, toTal, Total are taken as 4 different variables.
A Variable should not be a keyword.
Note that variables are also called as identifiers
Valid Variable | Invalid Variable | Reasons |
name | "name" | quotation marks not allowed |
marks200 | marks 200 | space is not allowed |
total_50 | total-50' | Single quotation marks not allowed |
STUDENTS10 | 10STUDENTS | It can not start with a digit |
Tags:
0 comments:
Post a Comment