3 Answers
3

Section 7.21.6.1p9 of n1570.pdf (the C standard) says, in relation to printf:

... If any argument is not the correct type for the corresponding
conversion specification, the behavior is undefined.

Section 7.21.6.1p8 states the correct type for the %f format specifier:

f,F A double argument representing a floating-point number is
converted to decimal notation in the style [−]ddd.ddd, where the
number of digits after the decimal-point character is equal to the
precision specification.

randomInRange returns an int. An int is clearly not a double, thus the behaviour is undefined. A chicken may run and jump around despite it's head being missing... That chicken might or might not cause someone to fall over and break their neck. Avoid headless chickens, and undefined behaviour.

Please consult the manual and try to find answers yourself before asking questions in the future. By doing so, you'll be helping to reduce the redundancy of this information on the internet.

so you mean the result is not "undefined" as @modifiable lvalue said ? It's just too small to be interpreted... right?
–
BinMar 8 '13 at 10:31

Even undefined behaviour is typically something. Changing the specifier to "%g" outputs 6.95316e-310, which is actually of type double, but I think the point is proven.
–
Aki SuihkonenMar 8 '13 at 10:45