With this function I'm finding the highest average, but after I find it I want to find the name that goes with the highest average. I'm pretty sure I need to use the index of the highest average but I don't know how to do it.
void findHighest(int numItems,string name[], double average[])
//loops through averages to find the highest average
{
int highest= average[0];
for (int i=0; i< numItems; i++)
{
if(average[i]>highest)
highest = average[i]; //i thing there needs to be something here for the index
}
cout << "Best percentage: " << highest << " %"<< " by " << name/* i get garbage here*/ << endl;
cout << " " << endl;
here is the output
"Best percentage: 100 % by 0x7fff61192948"