1.
A void function can return any value
true or false?
2.
The following is legal in a void function
return;
true or false?
3.
In a function with call-by-reference parameters, any changes to the formal
parameters will change the actual arguments passed to the function.
true or false?
4.
It is acceptable to have both call-by-value and call-by-reference parameters in the
same function declaration.
true or false?
5.
A stub is a function that is completely defined and well tested
true or false?
6.
Which of the following is a legal call to the displayOutput function?
void displayOutput(int total);
A. 
Void displayOutput(myTotal);
B. 
DisplayOutput(int mytotal);
C. 
D. 
7.
The precondition(s) for a function describe
A. 
What is true after the function is executed
B. 
C. 
D. 
What must be true before the function executes
8.
Which of the following is true for a void function?
A. 
There cannot be a return statement.
B. 
The value of void should be returned.
C. 
The value of 0 should be returned.
D. 
9.
What is the output of the following function and function call?
void calculateCost(int count, float& subTotal, float& taxCost);
float tax = 0.0,
subTotal = 0.0;
calculateCost(15, subTotal,tax);
cout << "The cost for 15 items is " << subtotal
<< ", and the tax for " << subTotal << " is " << tax << endl;
//end of fragment
void calculateCost(int count, float& subTotal, float& taxCost)
{
if ( count < 10)
{
subTotal = count * 0.50;
}
else
{
subTotal = count * 0.20;
}
taxCost = 0.1 * subTotal;
}
A. 
The cost for 15 items is 3.00, and the tax for 3.00 is 0.30;
B. 
The cost for 15 items is 0.00, and the tax for 3.00 is 0.00;
C. 
The cost for 15 items is 0.00, and the tax for 3.00 is 0.30;
D. 
The cost for 15 items is 3.00, and the tax for 3.00 is 0.00;
10.
What is the output of the following function and function call?
void calculateCost(int count, float& subTotal, float taxCost);
float tax = 0.0,
subtotal = 0.0;
calculateCost(15, subtotal,tax);
cout << "The cost for 15 items is " << subtotal
<< ", and the tax for " << subtotal << " is " << tax << endl;
//end of fragment
void calculateCost(int count, float& subTotal, float taxCost)
{
if ( count < 10)
{
subTotal = count * 0.50;
}
else
{
subTotal = count * 0.20;
}
taxCost = 0.1 * subTotal;
}
A. 
The cost for 15 items is 3.00, and the tax for 3.00 is 0.30;
B. 
The cost for 15 items is 0.00, and the tax for 3.00 is 0.00;
C. 
The cost for 15 items is 0.00, and the tax for 3.00 is 0.30;
D. 
The cost for 15 items is 3.00, and the tax for 3.00 is 0.00;
11.
Which of the following function prototypes are not valid?
A. 
Void doSomething(int& x, int y);
B. 
Void doSomething( int& x, int& y);
C. 
Void doSomething( int x, int y);
D. 
12.
What is the value of choice after the following statements?
void getChoice(int& par_choice, in par_count);
int choice, count=3;
getChoice(choice, count);
void getChoice(int& par_choice, in par_count)
{
if(par_count<0)
par_choice =0;
if(par_count = 0)
par_choice=-1;
else
par_choice=99;
return;
}
A. 
B. 
C. 
D. 
13.
If you were to write a function for displaying the cost of an item to the screen,
which function prototype would be most appropriate?
A. 
B. 
Void display(float myCost);
C. 
Int display (float myCost);
D. 
14.
Given the function definition
void something ( int a, int& b )
{
int c;
c = a + 2;
a = a * 3;
b = c + a;
}
what is the output of the following code fragment that invokes something?
(All variables are of type int.)
r = 1;
s = 2;
t = 3;
something(t, s);
cout << r << ' ' << s << ' ' << t << endl;
A. 
B. 
C. 
D. 
E. 
15.
Given the following function declaration and local variable declarations, which of
the following is not a correct function call?
int myInt;
float myFloat;
char ch;
void someFunction(int& first, float second, char third);
A. 
SomeFunction(1, 2.0, ch);
B. 
SomeFunction(myInt, myFloat, ch);
C. 
SomeFunction(myInt, 2.0, 'c');
D. 
SomeFunction(myInt, myFloat, '1');
16.
In the following function, what is passed to the first parameter?
void f1( int& value1, int value2);
int x,y;
f1(x,y);
A. 
B. 
Nothing, it is a void function
C. 
D. 
The variable x (or its memory location)
17.
A simplified main program used to test functions is called
A. 
B. 
C. 
D. 
18.
Which of the following comments would be the best post-condition for this swap
function void swap( int& left, int&right);
A. 
B. 
//Postcondition: the values of left and right are exchanged.
C. 
//Postcondition: left has the value of right
D. 
//Postcondition: left and right are unchanged
19.
What is wrong with the following code?
int f1( int x, int y)
{
x = y * y;
return x;
int f2( float a, float& b)
{
if(a < b)
b = a;
else
a=b;
return 0.0;
}
}
A. 
Neither function should return a value
B. 
Function definitions may not be nested
C. 
Both parameters to f2 should be pass-by reference
D. 
In f2, a can not be assigned b.
E. 
20.
Testing your program should be done
A. 
As each function is developed
B. 
C. 
Only if there appear to be problems
D. 
Only if your instructor requires it.