33. What, if anything is required to fix the following code?
char val1, val2;
val1 = 10;
val2 = 25;
printSum(val1, val2);
void printSum(int x, int y)
{
cout << “The sum is: ” << x + y << endl;
}
val1 and val2 should be passed by reference
nothing is required, the code is correct
the x and y variables should be named val1 and val2
val1 and val2 are the wrong type
34. What is the scope of the variables listed in a function?
referential to the function
global to the main() function
35. What type of functions do not return a value after completing their task?
36. Which of the following looks like a typical call to a void function?
37. When passing a variable by reference to a function, must the formal parameters have the same exact name as their
corresponding actual parameters?
38. Is it possible to pass a variable to a function by reference and have the value stored in the original actual parameter
remain unchanged?
39. Write a void function called getAge that has one formal parameter of the int data type. The function should prompt the
user for their age and return the value through the parameter.
An example of the call to the function could be as follows, where the variable age has been declared to be of the int data
type.
getAge(age);
40. What are the two main differences between the syntax for creating a value-returning function and the syntax for
creating a void function?
41. Give an example of a function that would be a good candidate to only utilize variables passed by value.
42. Given the program segments below (one from the main function, and one program-defined function called calcSum),
what would be printed in the main program for the variable sum after the function is called? Assume an appropriate
function prototype has been declared.