Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compound Operators 03/07/11. More Operators, First Section 4.4.

Similar presentations


Presentation on theme: "Compound Operators 03/07/11. More Operators, First Section 4.4."— Presentation transcript:

1 Compound Operators 03/07/11

2 More Operators, First Section 4.4

3 Compound Operators Common to have variable on both sides of assignment. sum = sum + data; Compound operators allow compact code. sum += data;

4 Compound Operators variable = variable op (expression)‏ can be written: variable op= expression

5 Compound Operators += -= *= /= %=

6

7

8 Increment and Decrement n++ ++n k-- --k Operands must be variables Change value of variables, side effect

9 Position of Increment/Decrement Where placed determines value used in the expression c = 5; cout << c++ ;cout << ++c;cout << c << endl; OUTPUT: 5 6 6 6


Download ppt "Compound Operators 03/07/11. More Operators, First Section 4.4."

Similar presentations


Ads by Google