Arithmetic
+
, -
, *
, /
(quotient operator), %
(remainder operator or modulus)
Divison and Modulus operator
in if then output is
in if then output is
Rules for arithmetic operators:-
-
Integer Divison
- int int is always int
-
Modulus with Integers Only
- Modulus operator cannot be used with floating point numbers as by default every float is treated as double. C is an expanding language.
// Example of incorrect usage: float result = 5.2 % 2; // Error
-
Operator Precedence
- If more than 1 operator is present in an expression then precedence rule will be applied.
4 Associativity
- If multiple operations with the same precedence appear, the associativity rule determines the order of evaluation.
- Arithmetic Operators are left associative.