I've read several questions that answer how this work, but not how to get around it. My program is scanning 10 floats using scanf and printing out the sum, min, max, and product of all the floats.
For example, given the input:
1.45 -2e2 -2e-2 14 -10.0 0.01 -0.02 20 -3e1 +4e+0
The program should produce:
Sum is -200.58000
Min is -200.00000
Max is 20.00000
Product is -389.76000
but instead it produces:
Sum is -200.58000
Min is -200.00000
Max is 20.00000
Product is -389.75999
I understand why this happens, but can anyone tell me how to get around this?
Here's my code:
#include <stdio.h>
int main() {
double min, max, sum, product;
printf("Sum is %.5f \n", sum);
printf("Min is %.5f \n", min);
printf("Max is %.5f \n", max);
printf("Product is %.5f \n", product);
}