Assignment Operators
The Assignment Operator evaluates an expression on the right of the expression and substitutes it to the value or variable on the left of the expression.
Example
x = a + b
Here the value of a + b is evaluated and substituted to the variable x.
In addition, C has a set of shorthand assignment operators of the form.
var oper = exp;
Here var is a variable, exp is an expression and oper is a C binary arithmetic operator. The operator oper = is known as shorthand assignment operator
* Only 1 variable is allowed on the left side of ‘=’.
Example :
z= k * i; is valid statement.
where k * i= z; is invalid statement.
- If a value is assigned to left side of ‘=’ , error message will be displayed on screen.
Example :
a+b=c;
Error : Lvalue required.
- An arithmetic instruction can be used for storing characters constants in character variables.
char a,b,d;
a = ‘F’;
b = ‘G’;
c = ‘+’;
When we do this, the ASCII value of the characters are stored in the variables. As ‘a’ stores 70(ASCII value of ‘F’), ‘b’ stores 71(G=71) and so on.



Recent Comments