Arithmetic is performed using the regular +
, -
, *
, /
and %
operators for addition, subtraction, multiplication, division and modulus respectively.
As in many programming languages, there are convenient variations on the assignment operator available for arithmetic manipulation as needed, namely +=
, -=
, *=
, /=
and %=
, corresponding to the appropriate arithmetic operators. Note that unlike some other languages, there are no increment or decrement operators.
If the user does not explicitly initialize a variable, the variable is set to zero. You can have explicitly uninitialized variables by typing a: int = ---
. Uninitialized variables have undefined behavior until a value is written to.
Just like the C programming language, *
, /
, and %
operators have higher precedence by default are evaluated first before evaluating +
and -
. Use parenthesis to change the evaluation order.