Write a program which finds the age and name of the oldest person in a group.

const int SIZE = 8;
int age[SIZE] = { 21, 42, 26, 22, 35, 13, 18, 39 };
string name[SIZE] = {“Mark”, “Rebecca”, “Fred”, “Alfred”, “Waldo”, ”Sue”, “Mary”, “Darrin”};

You must use the computer to write this program. You must use arrays and functions to write this program.

Note: The data should not be able to be changed inside the function.

go online. whatever you are trying to do, someone has already done it and posted the code.

just write a loop that traverses the array, saving the index of biggest value so far.
Presumably, you will also need to display the person and age found.

Here's a step-by-step breakdown of how to write the program:

Step 1: Define the required arrays.
- Create an array "age" with elements [21, 42, 26, 22, 35, 13, 18, 39].
- Create an array "name" with elements ["Mark", "Rebecca", "Fred", "Alfred", "Waldo", "Sue", "Mary", "Darrin"].

Step 2: Define functions to find the oldest person's name and age.
- Create a function "findOldestAge()" that takes the "age" array as an input and returns the oldest age.
- Inside the function, find the maximum age in the array using a loop and the "max" function.
- Return the oldest age.

Step 3: Create a function "findOldestPerson()" to find the oldest person's name.
- Pass both "age" and "name" arrays as inputs to the function.
- Inside the function, find the oldest age using the "findOldestAge()" function.
- Use a loop to search for the index of the oldest age in the "age" array.
- Return the corresponding name from the "name" array.

Step 4: Implement the main function to call the "findOldestPerson()" function.
- In the main function, call the "findOldestPerson()" function and store the result in a variable.
- Print the oldest person's name and age.

Here's the complete program:

```cpp
#include <iostream>
#include <algorithm>
using namespace std;

const int SIZE = 8;
int age[SIZE] = { 21, 42, 26, 22, 35, 13, 18, 39 };
string name[SIZE] = { "Mark", "Rebecca", "Fred", "Alfred", "Waldo", "Sue", "Mary", "Darrin" };

int findOldestAge() {
return *max_element(age, age + SIZE);
}

string findOldestPerson(int age[], string name[]) {
int oldestAge = findOldestAge();
for (int i = 0; i < SIZE; i++) {
if (age[i] == oldestAge) {
return name[i];
}
}
return "";
}

int main() {
string oldestPerson = findOldestPerson(age, name);
int oldestAge = findOldestAge();
cout << "Oldest Person: " << oldestPerson << endl;
cout << "Oldest Age: " << oldestAge << endl;
return 0;
}
```

When you run this program, it will output:
```
Oldest Person: Rebecca
Oldest Age: 42
```

Sure! Here's a program written in C++ that finds the age and name of the oldest person in a group using arrays and functions:

```cpp
#include <iostream>
#include <string>
using namespace std;

const int SIZE = 8;
int age[SIZE] = { 21, 42, 26, 22, 35, 13, 18, 39 };
string name[SIZE] = { "Mark", "Rebecca", "Fred", "Alfred", "Waldo", "Sue", "Mary", "Darrin" };

void findOldestPerson(int ages[], string names[], int arraySize, int& maxAge, string& oldestName) {
maxAge = ages[0];
oldestName = names[0];
for (int i = 1; i < arraySize; i++) {
if (ages[i] > maxAge) {
maxAge = ages[i];
oldestName = names[i];
}
}
}

int main() {
int maxAge;
string oldestName;
findOldestPerson(age, name, SIZE, maxAge, oldestName);

cout << "The oldest person is " << oldestName << " with age " << maxAge << endl;

return 0;
}
```

In the main function, we declare the variables `maxAge` and `oldestName` to store the age and name of the oldest person. Then, we call the function `findOldestPerson` and pass in the array of ages, array of names, the size of the arrays, and the `maxAge` and `oldestName` variables by reference.

Inside the `findOldestPerson` function, we initialize the `maxAge` and `oldestName` with the first element of the arrays. Then, we iterate through the rest of the elements and compare each age with the current `maxAge`. If a higher age is found, we update the `maxAge` and `oldestName` accordingly.

Finally, in the `main` function, we print the result by accessing the `oldestName` and `maxAge` variables.

This program will output:

```
The oldest person is Rebecca with age 42
```