Name: ________________________________

Honor Code Acknowledgment: _____________________________


CPS 6, Summer 1999                 Random Quiz 8

Due: Tuesday, June 15, 1999                 8 points


Use the following definition for problems 1 and 2.

struct Member
{
  string name;
  int age;
};

Problem 1: How many Older? (4 pts)

Write a function named NumGreater that given a vector of type Member, the number of elements in the vector, and a specified age, returns the number of members with age greater than "age".

For example, consider the following vector of type Member named FrenchClub with 5 elements.

NumGreater(FrenchClub, 5, 35) returns 4 (4 members have age greater than 35) and NumGreater(FrenchClub, 5, 42) returns 1.

int NumGreater(const Vector <Member> & club, int num, int age)
// precondition: num > 0 is the number of entries in the vector Club
// postcondition: returns the number of members with age greater 
//                than "age"
{















Problem 2: Eldest Member (4 pt)

Write a function named Eldest that given a vector of type Member and the number of elements in the vector, returns the name of the eldest member. If there is more than one member with the oldest age, return the name of any eldest member.

For example, in the figure above, Eldest(FrenchClub, 5) returns "Fritz".

string Eldest(const Vector <Member> & club, int num)
// precondition: num > 0 is the number of entries in the vector club
// postcondition: returns the name of the eldest club member.
//               If there is more than one member of oldest age, then
//                  return the name of any eldest member                 
{