1.
If a function needs to modify more than one variable, it must
A. 
B. 
C. 
D. 
Be a call by reference function
2.
When a void function is called, it is known as
A. 
B. 
C. 
D. 
3.
What is the output of the following code fragments?
int trial( int& a, int b)
{
if(b > a)
{
a=b;
return –a;
}
else
{
return 0;
}
}
float x=0, y=10,z;
z=trial(y,x);
cout << z << " " << x <<" " << y << endl;
A. 
B. 
C. 
D. 
4.
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
5.
Call-by-reference should be used
A. 
B. 
When the function needs to change the value of one or more arguments
C. 
D. 
6.
A simplified main program used to test functions is called
A. 
B. 
C. 
D. 
7.
When a variable is local to a function, we say that it has ___ of the function
A. 
B. 
C. 
D. 
8.
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.
9.
If you write a function that should use call-by-reference, but forget to include the ampersand,
A. 
The program will not compile
B. 
The program will not link
C. 
The program will not run without a run-time error
D. 
The program will run but probably not give you the correct information.
10.
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. 
11.
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)
12.
the fabs(double num) function
A. 
Returns the most fabulous number
B. 
Returns the largest whole number
C. 
Returns the negative value of num
D. 
Returns the absolute value of num
13.
What is the output of the following program fragment?
cout << static_cast<int>(3/4) << endl;
A. 
B. 
C. 
D. 
14.
If you need to write a function that will compute the cost of some candy, where each piece costs 25 cents, which would be an appropriate function declaration?
A. 
Int calculateCost(char name);
B. 
Char calculateCost(int count);
C. 
Int calculateCost int count;
D. 
Int calculateCost(int count);
15.
What is the value returned by the following function?
int function()
{
int value = 35;
return value + 5;
value += 10;
}
A. 
B. 
C. 
D. 
16.
When overloading a function, what must be true?
A. 
The names should be different with the same number and/or types of parameters.
B. 
The names should be the same with different number and/or types of parameters.
C. 
The names should be different with different number and/or types of parameters.
D. 
The names should be the same with the same number and/or types of parameters.
17.
When parameters are passed between the calling code and the called function, parameters and arguments are matched by:
A. 
B. 
Their relative positions in the parameter and argument lists
C. 
D. 
They are not matched up at all.
18.
The expression static_cast<int>(3) is called a
A. 
B. 
C. 
D. 
19.
If the variable x has the original value of 3.4, what is the value in x after the following?
cout << static_cast<int>(x);
A. 
B. 
C. 
D. 
20.
What is the value of the following?
sqrt(sqrt(pow(2,4)));
A. 
B. 
C. 
D. 
21.
What is the value of i after the following function call?
//function definition
int doSomething(int value)
{
value = 35;
return value;
value = 13
}
//fragment of main program
int i=0;
cout << doSomething(i);
A. 
B. 
C. 
D. 
22.
What is the output of the following code fragement?
double size, volume=16.0;
size = sqrt(sqrt(volume)) / 3;
cout << fixed << showpoint <precision(2);
A. 
B. 
C. 
D. 
23.
Information Hiding is analogous to using
24.
What is the output of the following function call?
//function body
int factorial(int n)
{
int product=0;
while(n > 0)
{
product = product * n;
n—;
}
return product;
}
//function call
cout << factorial(4);
A. 
B. 
C. 
D. 
25.
Which of the following are equivalent to (!(x<15 && y>=3))?
A. 
B. 
C. 
D.