This preview shows page 1. Sign up to view the full content.
Unformatted text preview: s, if given are evaluated from
Then multiplication and division is performed from
After it, addition and subtraction are performed from 11 left to
left to 11 Assignment Operator The operator which is used to assign value of an expression to variable
is called Assignment operator.
It has the general form as:
Variable = expression;
Where expression may be constant, another variable to which a value
has previously been assigned or a formula to be evaluated. Examples
c = a+b;
Assignment statement may be written in compound form as
int a=b=c=50; 12 Arithmetic Assignment Operators The arithmetic assignment operator is the combination of arithmetic
and assignment symbols they are unique to C++.
+=, -= , *=, /= and %=
For example, consider the following statement
Sum = Sum + num;
We could write this statement as
Sum + = num;
The effect is exactly the same but the expression is more compact.
Some more examples are:
Sum -= num is equivalent to
Prod *= num is equivalent to Sum = Sum – num
Prod = Prod * num 13 13 Relationa...
View Full Document
- Spring '14