Q A Reason ------------------------------------------------------------------------------- 1 2 The parameters are matched by their relative positions. The compiler will check the types to make sure they are compatible. The function prototype and header determine which parameters are input only, and which ones are input and output. 2 1 Pass by value is an input only parameter passing technique. 3 8 Answers 3 and 4 are both valid, which is not an option. Answers 1 and two are not valid because you cannot pass the literal constant 6.85 by reference. 4 4 Since both parameters are input and output parameters the only prototype that works is 4), which passes both parameters by reference. 5 5 Without the ampersand (&), you are passing by value. You can pass any of 1, 2, or 3 by value. 6 6 The variable r is local to Twist, so any modification in Twist is lost. The variable t is passed by reference to the formal parameter a. Thus, a = a * 3 stores 9 in t as a result. The variable s is passed by reference to the formal parameter b. Thus b = r + a, which is 5 + 9 = 14, results in 14 being stored in s. 7 5 The first statement is true. The second statement is false, you can modify the formal parameter, but the actual parameter is left alone so any changes made are lost when the function completes. The third statement is false. You can pass expressions, variables, or constants by value. The fourth statement is true. 8 3 The actual parameter can be a variable. In addition, the actual parameter can be a named constant, but NOT a literal constant. 9 6 Statements 1, 2, and 3 are false, so the best answer is not available. 10 2 The first parameter is pass by reference, so when you change intVal in Demo, it changes myInt to 40 as a result of the invocation. The second parameter is pass by value, so any change made to floatVal is lost when the function completes. 11 2 Even though gamma is pass by reference, the function does not use the value stored in gamma initially. This function might be better written as a value returning function. 12 2 Because exp is passed by reference, when you invoke Power(n, pow) changes made to exp affect pow. The while loop terminates when exp is 0, thus when pow is 0. 13 1 Pass by value is always one-way into the function. 14 3 We are both assigning to and evaluating gamma in the assignment statement. So this is a two-way communication. 15 2 It can't be a global variable, because global variables are normally accessible to several functions, including main(). It can't be an actual parameter, because the actual parameter comes from OUTSIDE of the function. Both local and formal parameters are accessible only within their function. 16 5 All of the statements are correct. 17 2 The variable alpha must be global because it's neither a parameter or local variable of Calc. 18 4 The important thing here is that the second definition of alpha is local to the if block. 19 2 The size of the array is 99 elements. All C++ arrays start with the valid index 0 and end with the valid index size - 1 = 98. 20 3 The number of times a digit appears in a file is an integer. We aren't sure exactly how many times that will be, so int is the best choice of data type element. There are 10 digits, ranging from 0 - 9, so an array of size 10 works perfectly. 21 3 The indices 4, 3, 2, and 1 are accessed in that order. 22 2 The first one prints out even indices only. The second one prints out Beta[2*0 + 1] = Beta[1], Beta[2*1 + 1] = Beta[3], ..., Beta[2*2499 + 1] = Beta[4999]. The third one prints out only the first 2500 elements, with each element multiplied by 2 and subtracting 1. 23 2 Parallel arrays must have the same size, so only 2 or 3 are valid possibilities. However, we are interested in storing the name and major for each student, so MAXSTUDENTS is the appropriate size. 24 4 You multiply the number of rows and columns. 25 3 Remember that C++ arrays have 0 based indices. 26 3 The array should be a character array given the declaration of alpha. The comment implies we are placing values into the array, so we must pass it without the const keyword. Adding a & is an error in C++, since arrays are pass by reference by default. 27 3 Again, we are placing values into the first parameter. 28 4 We are not modifying the second parameter, so we should make sure that we do not modify the second parameter by using the const keyword. 29 3 You cannot assign one array to another. Answer 2 is a syntax error. Answer 3 is the only possibility, and certainly a function can be written to copy two arrays. 30 7 The second one won't work, but we can always read in each element one at a time, which the other three possibilities are doing.