FINDING LOWEST VALUE OF AN ARRAY

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
Inside the loop, set highest, but don't display it. After the loop exits, display highest.
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 ??????
Personally, I would use the Standard Library because there somebody else has already done all the work for me; no thinking required. http://www.cplusplus.com/reference/algorithm/minmax_element/
Topic archived. No new replies allowed.