May 2, 2018 at 6:38pm UTC
How could I find lowest value of array. then display student id
void compare(string studentID[],double studentScore[], int &s){
double highest = 0.0, lowest = 40.0;
for(int i=0;i<s;i++){ // find highest value
if (studentScore[i] > highest){
highest = studentScore[i];
cout<<studentID[i] << endl;
}else if (studentScore[i] == highest){
cout << studentID[i] << endl;
}
}
here is some of sample data.
ID Score
137001 40
137002 38
137003 35
137004 32
137005 11
137006 0
137007 34
137010 21
137011 40
the output should only dispaly
137006
May 2, 2018 at 7:24pm UTC
Inside the loop, set highest, but don't display it. After the loop exits, display highest.
May 2, 2018 at 8:02pm UTC
The title and first line of the post are about finding the lowest.
Also the result should be the lowest.
Why do you want to find the highest later ??????