You're right. I didn't even catch that. I normally use a break-point test in my loops ( though I didn't include one here ). I didn't load the index value into high due to the fact that ( as I understood it ) he needs to return the value and the index.
Originally posted by Unregistered
I'm not quite sure about this but it looks like the code above would give you 5 for a value of x every time.
What I should have put was:
Thanks for catching that!
int i, x=1, high=dollar;
cout<<"High value: "<<high<<" found at index: "<<i<<endl;