Assignment Operators

I l @ ve RuBoard

Assignment Operators

= assigns the value at its right to the lvalue on its left.

Each of the following assignment operators updates the lvalue at its left by the value at its right, using the indicated operation. We use R-H for right-hand and L-H for left-hand.

+= adds the R-H quantity to the L-H variable and places the result in the L-H variable.

-= subtracts the R-H quantity from the L-H variable and places the result in the L-H variable.

*= multiplies the L-H variable by the R-H quantity and places the result in the L-H variable.

/= divides the L-H variable by the R-H quantity and places the result in the L-H variable.

%= gives the remainder from dividing the L-H quantity by the R-H quantity and places the result in the L-H variable.

&= assigns L-H & R-H to the L-H quantity and places the result in the L-H variable.

= assigns L-H R-H to the L-H quantity and places the result in the L-H variable.

^= assigns L-H ^ R-H to the L-H quantity and places the result in the L-H variable.

>>= assigns L-H >> R-H to the L-H quantity and places the result in the L-H variable.

<<= assigns L-H << R-H to the L-H quantity and places the result in the L-H variable.

Example

rabbits *= 1.6; is the same as rabbits = rabbits * 1.6;

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net