Variable:
An entity that may very during program exaction is called a variable. Variable names are names given to locations in memory. These locations can contain integer, real or character constants. In any language, the type of variables that is can support depends on the types of constant that it can handle. This is because of a particular type of variable can hold only the same type of constant.
Types of C Variable:
1) Integer Variable.
2) Float Variable.
3) Character Variable.
1) Integer Variable:
An integer variable can hold only an integer constant value. Integer variable declare by reserve word (int) mean integer.
For example:
int a :
int is the type of variable and a is the name of the variable.
a=5, d=745, t=43 etc.
2) Float Variable:
A real variable can hold only real constant value. Float variable declare by reserve word ( float ).
For example :
float a;
a=7.2, g=1.342, d=421.67 etc.
3) Character Variable:
Character variable can hold only a character constant. Character variable is declared by reserved word ( char) mean character.
For example:
char a;
a=*b*, a=*5*, a= *+*
Note:
in character its not (*) its inverted commas.
For example:
char a;
a=*b*, a=*5*, a= *+*
Note:
in character its not (*) its inverted commas.
Rules for constructing variable names:
1) A variable name is any combination of 1 to 8 characters but we can give up to 256.
2) The first character in the variable name must be an alphabet or underscore.
3) No commas or blanks are allowed with in a variable name.
4) No special symbol other than an underscore can be used in a variable name.
5) Variable name must be meaning full.
For example:
si_int , hra, pop_e_89, jack, etc.
Note:
These rules remain same for all types of primary and secondary variables.
No comments:
Post a Comment