Operators
Arithmetic Operators
- +, – , *, / and the modulus operator %.
- + and – have the same precedence and associate left to right.
3 – 5 + 7 = ( 3 – 5 ) + 7 3 – ( 5 + 7 )
3 + 7 – 5 + 2 = ( ( 3 + 7 ) – 5 ) + 2 - *, /, % have the same precedence and associate left to right.
- The +, – group has lower precedence than the *, / % group.
3 – 5 * 7 / 8 + 6 / 2
3 – 35 / 8 + 6 / 2
3 – 4.375 + 6 / 2
3 – 4.375 + 3
-1.375 + 3
1.625
The following table shows all the arithmetic operators supported by the C language. Assume variable A holds 10 and variable B holds 20 then