It looks like your indexHigh function is determining what the highest score is in the array, right? Then you return that value as in the subscript of the one in question.
Hmm, what syntax error are you getting?
Yeah, I couldn't figure out how to declare the function from within the array; the "." was throwing me off. My syntax error was saying:
no operator found which takes a right-hand operand of type 'const studentType' (or there is no acceptable conversion). I got it now, thanks tummy :)
Hmmm...I think I see what you mean....I haven't been introduced classes or operatior overloading yet though and I'm trying to accomplish this per assignment requirements:
I do know that structs are a class in which all functions are public.
Your program MUST consist of the following:
A function to read the students' data into the array.
A function to assign the relevant grade to each student.
A function to find the highest test score.
A function to print the manes of the students having the high score.
Actually I have the syntax right now, my semantics need a little work as I keep printing the last persons' name entered, not the highest score for some reason..
Thank you for the input balckcoder41 :)
lol...somehow I changed the greater than operator a few hours ago and it worked....I don't understand the logic at all....
1 2
if(list[max].score > list[index].score)
max = index;
does this not mean if( the location of list, variable score, is greater than the location of list, variable socre)
max = stores the value of location;
I dont't get how the operator should be < but it IS semantically correct.
Explain please? I thought I learned how to manipulate arrays correctly :( now I'm confused again
int indexHigh(const studentType list[])
{
int index, max = 0; //max=0; it assumes that index 0 has the
//highest value
for(index = 0; index < 5; index++)
//we check evey value in the array if the next
//is higher then the value store in max is not
//the highest so we change it this higher value
if(list[max].score < list[index].score)
max = index;
return max;
}
it's like a boxing game, everyone challenges the champion, and if that challenger wins then his the new champion.. hope that makes sense..