Write a program that reads in a list of names and ages until the user enters "quit" as a person’s name. When the sentinel (quit) appears as the name, your program should display the name of the oldest person in the list and then terminate. For example, with the list of entries
Tommy
17
Don Hodges
42
Kathy
51
Ken Summers
19
Elsa Turner
35
quit
the program will print
The oldest person is Kathy.

#include<iostream>
using namespace std;
int main()

    int age;
    string name="";
    cout<<"Enter the Person's name: "<<endl;
    getline(cin,name);
    cout<<"Enter the person's age: "<<endl;
    cin>>age;
    while(name!='quit')
    {
        name++;
        cout<<"Enter the next person's age: "<<endl;
        getline(cin,name);
        cout<<"Enter the next person's age: "<<endl;
        cin>>age;
        age++;
    }
return 0;


}
This is what i have done. But it seems to be giving me errors. I'm new to c++ and have no idea how to proceed.

Did you try to do this with pseudocode to see what the operations are? The folowing pseudocode should help you with how you need to write the program.

number age = 0,  max = 0;
string name, oldest
while(true)
    get name
    if name == "quit"
        break
    get age
    if age > max
        max = age
        oldest = name
end while
display << "the oldesy person is " << oldest
This article has been dead for over six months. Start a new discussion instead.