|This is why you should always initialize your variables to avoid this problem. You should do this instead:|
double mmin = 0.0, mmax = 0.0;
You should always initialise variables to sensible values. Those are not sensible values for this situation.
For example, if all numbers in the set being examined were above 0.0, the minimum would incorrectly be determined to be 0.0.
Similarly, if all the numbers were below 0.0, the maximum would incorrectly be determined to be 0.0.
should be initialised to the highest possible value, so that it is guaranteed to be reduced to one of the numbers in the set.
should be initialised to the lowest possible value.
Alternatively, both can be initialised to the value of the first element in the set (or, indeed, any member of the set) - which is exactly what jonnin did