Koofer Test 2 Key For questions 1 and 2, the while loop body is executed three times: count: 3 6 12 24 pass: 2 3 4 5 1 c 2 c 3 c As opposed to a do-while (evaluated at end). 4 f while and for; switch and if...else are selection mechanisms 5 e &'s in the prototype and definition header 6 b Execute "case 0" clause, changing anInt to 0. 7 d Execute "case 1" clause, but no break, so falls through to the break in "case 3" and sets anInt to 11. 8 a anInt == 11, so executes default clause For questions 0 and 10: First is passed by reference, Second by value. The first assignment in Remainder() changes the value of First to 117%11, which is 7. The second assignment in Remainder does not change Second. 9 c 10 a 11 a Nothing in this program changes the value Temp is initialized to. Remember the scope rules. 12 b First and Second are passed by value, so neither is changed. For questions 13-15: notice that x is an int, so the assignment makes x == 2, not 2.6. Also notice that there is no local variable Temp in QuadFunc(), so the assigment there modifies the global float variable Temp. Now just do the arithmetic, and Temp == 9.5. Finally, the return value for QuadFunc() is int, so the value 9 is returned and printed. 13 b 14 c 15 f 16 a 17 b (at least not unless you pass them as parameters) 18 b Can't assign an array to an array (use for loop instead). 19 b Can't add arrays (or do assignment for that matter). 20 a Adds fourth element of first[] and fourth element of second[], storing the result in the fourth cell of third[] 21 a Adds second element of first[] and third element of second[], storing the result in the first cell of third[] 22 a 23 b First parameter to DoSomething() must be an array; first[3] is just a simple int variable. 24 a 25 e display() prints: {-4, 0, 1} 26 c 27 d f3() calculates: 3*-4 + 2*0 + 1*2 == -10 28 g f2() modifies only its first parameter For questions 29-32: the point here is scope. 29 b passed to MaxVal() in call after line 6 30 a 31 c line 7 refers to the local Big, declared in line 6 and not modified by MaxVal() 32 a MaxVal() doesn't have a local Big, nor is Big passed as a parameter -- therefore MaxVal() must reference the global Big 33 c We haven't covered this yet; in any case, binary search only For questions 34-38, we haven't covered sorting yet either. However, this is just asking to reproduce code given in the notes. 34 c 35 a 36 a 37 c 38 d 39 b 40 e The formal parameter is an alias for the actual parameter, but the function is forbidden to modify the value of the formal parameter (enforced by the compiler).