You need %lf
for double
s with scanf
, and you also need two of these if you have two double
s to read.
So change:
scanf("%f", &low, &high);
to:
scanf("%lf %lf", &low, &high);
Also change:
scanf("%f",&n);
to:
scanf("%lf",&n);
Note: error checking is always a good idea - scanf
returns the number of values successfully processed. So you could check whether the first scanf
call is working like this:
if (scanf("%lf %lf", &low, &high) != 2)
printf("scanf failed!\n");