Exercise #9
Suppose we had an array of names, called people, in which each name is stored using a minimum number of characters (no trailing blanks)followed by a null character. We also have an array that is parallel to people called books; it contains int values that represent the number of books owned by the people in the people array. Below are the declarations of the arrays. If each of the arrays contains count entries, show how we can write C++ statements to display the people's names and number of books in a clean column format.
typedef char PersonName[25];
PersonName people[100];
int books[100]
int count;
A "clean" column format might look something like this:
Person's Name Books
John Doe 67
Elizabeth Alexander 1022
Mary Ellen Sams 233
Larry Smith 15
Neil Masterson 177
. .
. .
Suppose we have a large array of scores from an examination; the scores are in no particular order; the array is called theTest. There are 1001 scores in the array. We have already seen how to find one basic statistic about exams (the average or mean). Two other simple statistics we have not tried to compute are the median (the middle score when the scores are put into sorted order) and the mode (the most frequently occurring score. Suggest how we can find these two statistics for theTest array, using methods that are as efficient as possible.