Name: ____________________________________________________ Alpha: _____________________

1. [20pts] Consider the following code snippet.
``````
double* A;
int N;
string name;
};

int main() {
int n;
cout << "There are " << n << " entries" << endl;
sort(A, n);
int k = search(A[0].A, 20, 75.5);
cout << A[0].A[k];
return 0;
}
``````
1. For each expression below, if it were used inside the main function, what would be the type of the expression? Write the type, or write "error" if it will cause a syntax error.

 expression type `A` `A.name` `A.A` `A[0].N` `A[0].A` `A[0].N[0]` `A[0].A[0]`
1. For each function used in the above code, write the prototype that would match the function.
```// write below the prototype of readfrom

// write below the prototype of sort

// write below the prototype of search

```
2. [80pts] Write a program that reads in a file like scoredata.txt (here's a small version to play with: smallscoredata.txt), which contains player names and game-scores for players playing an online game, and prints out the names in the usual alphabetical order, followed by the highest score acheived by that person. A run on the small file would look like this:
```~/\$ ./prog
smallscoredata.txt
Betty Johnson 2400
Andy Smith 800
Betty Smith 2300```
I have two pieces of advice. First, I would delcare a struct that represents the data in a row of the file. Second, I would sort the data first as shown below (i.e., by the last name, then the first name, then the score), and then run through the sorted data in order to pull out each individual's highest score. In fact, if you just get the sorting done right, you'll get most of the credit.
 smallscoredata.txt sorted the "right way" ```10 Betty Smith 900 Betty Johnson 1600 Betty Johnson 2400 Andy Smith 800 Betty Smith 1200 Betty Smith 2200 Betty Johnson 1600 Andy Smith 200 Betty Smith 2300 Betty Johnson 1900 ``` ``` Betty Johnson 2400 Betty Johnson 1900 Betty Johnson 1600 Betty Johnson 1600 Andy Smith 800 Andy Smith 200 Betty Smith 2300 Betty Smith 2200 Betty Smith 1200 Betty Smith 900 ```