Maximum and Minimum in Arrays

Pages: 123
Hint: what if x[0] is negative, but still the largest negative value?
I understand what you're saying, but I'm not exactly sure how to apply it. This is what I have now. Still the wrong value.

for (int i=0; i <= n-1; i++)
{
// NEGATIVE MIN
if (x[i] < 0.0 && x[i] < negativeMax)
negativeMin = x[i];
}
cout << " Minimum negative value = " << fixed << setprecision(2) << setw(8) << right << negativeMin << endl << endl;
Closer. Now it's going to update any time the number is less than the negative max.

@Duoas and OP
Sorry. I looked at the post and thought OP said he/she solved it, so I thought it would be fun to try my own version and post it. Sorry.
Topic archived. No new replies allowed.
Pages: 123