Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hoping someone can help me this. I have a 1D array of average stored in a array:

ID: 3541449 • Letter: H

Question

Hoping someone can help me this. I have a 1D array of average stored in a array: averages[55]. I have to find the highest average and the index or position of the highest average.... I have successfully found the highest average, but I am having trouble getting the index to come out right... I would greatly appreciate the help. Here is my code below. Thanks in advance and I will rate.


float temp = 0.0;

for (int j = 0 ; j < 55; j++)

{

if (averages [ j ] > temp)

{

temp = averages [ j ];

int index = j;

}

}

cout << " The highest average value is " << temp << endl;

cout << "The position of the highest average value is "<< index << endl;

Explanation / Answer

The position in normal terms ( where you start counting by 1 and not 0) would be index plus 1.