3. Assignment Statements
Arithmetic operators: multiply, divide, add, subtract: * / + -
Add one, subtract one: ++ --
Also mod, for integers only: % (remainder after division, e.g. (7 % 4) == 3)
Store result of expression at storage location specified by identifier:
identifier = expression; a = b+c*d; a = (b+c)*d;
Also: *= /= += -= %= a += 5; /* add 5 to a */
examples
---
Nested form for polynomial evaluation (Horner's Rule),
to minimize number of multiplications:
Math: p = a x3 + b x2 + c x + d
C: p = a*x*x*x + b*x*x + c*x + d;
p = (a*x*x + b*x + c)*x + d;
p = ((a*x + b)*x + c)*x + d;
nth degree poly, n multiplications
Practice!