Key for Homework 7 on Functions Q A Reason ----------------------------------------------------------------------------------- 1 6 Actual parameters that are passed by reference must be variables; that rules out answers 2 and 4. 2 2 Gamma is passed by reference, and the function assigns Gamma a value, so there is definitely communication from the function to the caller. Since the value Gamma had when the call was made isn't used, there's no communication from the caller to the function. 3 1 The value Gamma had when the call is made is used by the function, so there is communication from the caller to the function. Gamma is passed by value, so even if the function changed its value, that would not affect the caller. Therefore, there is no communication from the function to the caller. 4 3 The value Gamma had when the call is made is used by the function in finding the new value which is assigned to Gamma, and Gamma is passed by reference, so the change to Gamma does affect the caller. 5 1 myInt is passed by value, so the function cannot change it. myDble is passed by reference, so the function does change its value, from 4.8 to 43.5 6 2 myInt is passed by reference, so the function does change its value from 20 to 40. myDble is passed by value, so the function cannot change its value. 7 2 The initialization is executed every time the function is called. There's nothing to prevent the function from changing the value of Beta, since Beta isn't declared as const. 8 2 The scope of alpha begins with the declaration and would extend to the end of the body of main in line 14, if there weren't another declaration of alpha within the body of the if. That declaration is in scope from line 7 through line 11. 9 4 The output statement within the if writes the value of the variable alpha which is declared in line 7 (which would be 5) and then the value of beta (which would be 25 due to the computation in line 8). The output statement in line 12 writes the value of the variable alpha which is declared in line 3 (which is 3), nad then the value of beta, which is still 25. 10 2 The variable Pow is passed to Power() by reference, so Power will decrement it all the way to zero before it returns. The value of N isn't changed by Power(), even though N is passed by reference. The correct value for N^Pow is computed and returned, and assigned to Result.