Chapter 4: Review Questions +++++++++++++++++++++++++++ :: 1. The shorthand expression for x = x + 10 is: a) x += 10; b) +x = 10; c) x =+ 10; d) x = 10+; 2. The result of the following arithmetic expression is? y = 6 * 4 % 3 * 5; a) 0 b) 9 c) 30 d) 40 3. What value does the computer give to the following expression if x is -4? ((x <= 5) && (x != 0) && (x >= -5)) a) 0 b) 1 c) 2 d) 3 4. What is the value of **sum** after the following expression? sum = 5 + 3 * 4 - 1 % 3; sum = __________ 5. True or False ___ a) i + j * l - k is evaluated as (i + (j * l )) - k ___ b) Logical operators evaluate left to right only if there is no higher precedence operator in the expression. ___ c) 10 % 3 yields a result of 3. ___ d) A side effect occurs when the same data item is used twice in an expression and changes value during at least one of the uses. 6. Evaluate the following expressions that use the arithmetic operators where i = 10, j = 2, and k = 3. Expression Result --------------------------------- -------------------- i - j * k i - i / j k % i + j i % 2 * k i + j * k - i / j 7. Evaluate the following logical expressions where i = 10, j = 2, and k = 3. Expression Result --------------------------------- -------------------- i - 2 * (j + k ) || i i - 2 * (j + k ) && i j = i || k j = i || k || j j - k || j && k 8. Identify what is wrong with the following expressions where i = 10, j = 2, and k = 3. Expression Result --------------------------------- -------------------- i ^^ j i =+ j ++i = j + k-- ( i || j ) = k - j 9. The expression, i = (k = x * y ) + (q ? r : s ); is equivalent to a) i = x * y + r; k = s; b) q ? r : s; k = x * y ; i = k + q; c) k = x * y; i = k + (q ? r : s); d) none of the above 10. What is the resulting type of the expression (int)q = (int)k - l + (char)m; given that k is float, l is float and m is int a. char b. float c. int d. long int