Variable declarations : -
Name of the memory location is called variable
Generally when we required to change the data of the time of execution then we need to go for variable,
- Before using any variable in the program, it must be declared first
- Declaration of variable means require to specify data type, name of the variable followed by semicolon(;)
- In ‘c’ programming language, variable declaration must be exist top of the program after opening the curly brace before writing first statement.
- In variable declarations, name of the variable must be starts with alphabet or ‘_’(underscore) only.
- Maximum length of the variable name is “32” characters, After 32 characters, compilers doesn’t consider remaining characters.
- In variable declarations, existing keywords, operators separators and constant values are not allowed.
- In variable declarations, at least single space should be required b/w data type & name of the variable.
- When we are declaring multiple variable of same datatype, we use “’” as separator.
- Inta; error
- Int a_ Error
- Int a;
- Int a b c; Error
- Int a,b,c;
- Int 1a,1b,c1; Error
- Int a1,b1,c1;
- Int abc,d;
- Int if; error10.
- Int If; yes
- Int If; yes case sensitive
- Int if., yes
- Int if; yes
- Int total-sal; error
- Int 1,2,3; error
- Int -1,-2,-3,yes
- Int -.,yes
o/p: 2 2.000000
Operator behaviour is always variable independent i.e Acc to the variable type, the behaviour of the operator will not be changed.
- Always the operator behaviour is operand dependant only
- e depends on the i/p data, the behaviour of the operator will change
- Always return value behaviour is variable dependant only. i.e depends on the variable type automatically return value will converted.
- In implementation, when operator is returning an integer value, we require to assign the data to float variable, then automatically data will be converted into float format by adding “.0”
- Whenever the operator i.e returning float value and we require to assign an integer variable then decimal point only require to assign.
By default, whenever we are declaring any variable, it bolds garbage value initially