2. (8 pts) A line of input consists of a name and height given in feet and inches. The following is an example:
John Smith 6 ft. 2 in.
4. ( 15 pts) Indicate the contents of x, y and z after each of the function calls below:
int one( int a, int b)
{
a = a + 1;
b = b + 1;
return a * b;
}
void two( int & a, int & b)
{
a = a * 2;
b = b * 3;
}
int main() // contents of x, y and z after each call
{ x y z
int x = 3, y = 2, z = 1; ---------------------
z = one(x, y); _____ _____ _____
two(y, z); _____ _____ _____
return 0;
}
5. ( 8 pts) What is the output of the following program fragment?
for (j = 2; j < 7; j++)
{
count = 0;
for (k = 2; k < j; k++)
if ( j % k != 0)
count++;
cout << j << " " << count << endl;
}
6. (20 pts) Complete the program below by filling in the following (All parts are independent):
void ReadVector(int A[], int size);
int Over60 (const int A[], int size);
int main( )
{
int count;
// FILL IN MAIN
return 0;
}
int Over60(const int A[], int size)
{
// FILL IN
}
7. (12 pts)
#include<fstream>
void Process(ifstream & in, ofstream & out);
int main( )
{
ifstream
ofstream
// FILL IN
return 0;
}
void Process(ifstream & in, ofstream & out)
{
// complete
}
9. ( 20 pts) Consider the struct illustrated below and the datatypes of its members.

(a) Give a declaration for a struct of type Candytype appropriate for the illustrated struct.
(b) Define a variable mycandy of this type and give all necessary statements to store the illustrated data.
(c) Define an array of size 4 of these structs named CandyOrder. Assuming the data has been stored, write a program fragment that sums the total number of boxes.
10. ( 8 pts) Write an equivalent
for statement for the
while statement below which uses the test
const int MAX = 12;
char letters[MAX];
int j = 0;
while (j< MAX)
{
if (letters[j] == 'A')
letters[j] = 'a';
j++;
}
11. ( 16 pts)
3. (8 pts) Consider the array
--------------------------------------- | 4 | 9 | 11 | 16 | 18 | 22 | 25 | 32 | ---------------------------------------(a) Which entries are checked during a binary search for the target 8?
4. (8 pts) Suppose the following vector is being sorted into ascending order:
----------------------------------- | 9 | 6 | 4 | 13 | 15 | 7 | -----------------------------------
(a) Illustrate the contents of the array after a single pass of the SelectionSort method .
----------------------------------- | | | | | | | -----------------------------------
(b) Illustrate the contents of the array after a single pass of the Insertion Sort method .
----------------------------------- | | | | | | | -----------------------------------