Electrical and Computer Engineering
38
of 48
UAH
CPE 112
Precedence Examples
•
Expression
Value
•
10 / 2 * 3 = 5 * 3 =
15
•
10 % 3 – 4 / 2 = 1 – 2 =
-1
•
5.0 * 2.0 / 4.0 * 2.0
•
= 10.0 /4.0 *2.0
•
= 2.5 * 2.0 =
5.0
•
5.0 * 2.0 / (4.0 * 2.0)
•
= 10.0 / 8.0 =
1.25
•
5.0 + 2.0 / (4.0 * 2.0)
•
= 5.0 + 2.0 / 8.0
•
= 5.0 + 0.25