Use your Notebook.
For each of the following examples, answer the questions. It is recommended that you solve for each line of code first and then you will have the answers readily available to you.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
// 1. Given the following code: var x = 20; var y = 30; var z, q; z = x + y; // (a) q = z - x; y = 40; z = x + y; // (b) // Answer: // 1a. what is the value of z at (a):________________________________ // 1b. what is the final value of q:_________________________________ // 1c. what is the value of z at (b):________________________________ // 2. Given the following code: var x = 1; var y = 2; var z = 3; var p, q, r; p = x + y; q = y * 2 + z; r = x + y * z; // Answer: // 2a. what is the final value of p: ______________________ // 2b. what is the final value of q: ______________________ // 2c. what is the final value of r: ______________________ // 3. Given the following code: var x = 10; var y = 30; var z = 25; var a, b; a = x + y + z; x = x + y; z = x + y; b = a + z; // Answer: // 3a. what is the final value of a:__________________ // 3b. what is the final value of x:__________________ // 3c. what is the final value of z:__________________ // 3d. what is the final value of b:__________________ |
Go back to: Operator Precedence