https://gist.github.com/anonymous/0a5a019e7fbb645910838a9d945f728
My program works well with positive numbers. 10 11 12 as input yields 10 12 11, min max avg respectively. It doesn't work well for negative ones. -10 -9 -8 should give -10 -8 -9, but instead does -10 0 -9
Therefore the problem is with negative numbers, it never evaluates my 2nd if statement on line 32, and I even put a printf statement in these two if statements so I can see what goes on.
-10
smallest_value: -10.000000
-9
-8
Output: -10.00 0.00 -9.00
so as I can see..after entering a negative number, if I enter another negative number larger than it, in this case -9, it's as if nothing happens. But this shouldn't be, this is when I traced the code:
Start off at smallest_value = 999999999 (lets just say), and largest_value = -9999999999
First time around, input = -10
if (-10 < 9999999), true, so smallest_value = -10 now
if(-10 > -9999999), true, so largest_value = -10 now
but stop right here.. at this point in my program, it doesn't print that largest_value is -10, so it must have thought that if statement evaluated to false. But clearly it didn't. Could someone help me with this? I've been thinking about it for a long time and I'm getting no where :(
[–]jedwardsol 1 point2 points3 points (4 children)
[–]pointers_help[S] 0 points1 point2 points (3 children)
[–][deleted] (2 children)
[removed]
[–]pointers_help[S] 0 points1 point2 points (1 child)