![]() | ![]() | ![]() | Arithmetic expressions |
< arithmetic expr. > | -> | < term > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < arithmetic expr. > < adding operator > < term > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< adding operator > -> + |- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< term > | -> | < factor > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < term > < multiplying operator > < factor > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< multiplying operator > ->
* |/ |% | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
< factor > | -> | ( < expression > ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < adding operator > < factor > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < variable > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < constant > | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | < function call > |
Co provides the usual addition, subtraction and multiplication
operations on integers. In addition, the quotient and remainder of
integer division operations can be obtained by using the '/
' and
`%
' operators respectively.
The unary '+
' and '-
' have the highest precedence among
arithmetic operators. Multiplying operators have the next highest
precedence followed by adding operators. Operators of equal precedence
group from left to right.
All expressions must have type integer. In particular, this implies that any variable used as an expression must have type integer.
![]() | ![]() | ![]() | Arithmetic expressions |