InterviewSolution
Saved Bookmarks
| 1. |
The expression x = -7%2-8 would evaluate to......... |
|
Answer» 2 - 8Let's FIRST understand the ORDER of PRECEDENCE of operators.By symbols:**, *, /, //, %, +, -By operation NAME:Exponentiation, Multiplication, Division Integer Division, Modulus, Addition, Subtraction.Applying the precedence to the expression,-7%2 - 8Modulus takes place first. In Modulus, only the remainder is taken.1 - 8What's left is subtraction.-7Therefore, -7%2 - 8 = -7. x = -7 |
|