48 Introduction to C++ Programming and Graphics
- Addition (+): We may write
c=a+b;- Subtraction (-): We may write
c=a-b;- Multiplication (*): We may write
c=a*b;- Division (/): We may write
c=a/b;- Modulo (%): We may write
c=a%b;This operator extracts the remainder of the divisiona/b. For example5%3 = 2Unconventional operators
In C++, we can write:a=b=c=0.1;with the expected result. A perfectly acceptable C++ statement is:
a=1+(b=3);meaning:
b=3;
a=1+b;Compound assignation
Other unconventional statements mediated by compound assignation
operators are listed in Table 3.1.1.