Puzzle R8

Print N random doubles MIN <= d < MAX

[H-1] Write a function double randDoubleRange(double min, double max) that returns a random double precision floating point value d in the range min <= d < max. As previously, the range includes min, but excludes max. This is the usual way that random number generators work. Test your function by writing a main().

[E-8]Example output from a program that tests this function for the range 5.0 <= d < 10.0 is:

 5.0062561035 7.8178405762 5.9664916992 9.0435791016 7.9249572754
 7.3992919922 6.7514038086 9.4796752930 9.1140747070 8.7329101563
 5.8705139160 9.2945861816 8.5523986816 7.5675964355 6.5199279785
 5.0749206543 5.4570007324 6.8222045898 5.7365417480 5.8294677734
 9.9424743652 7.2283935547 5.5953979492 5.0233459473 5.0445556641
 6.8893432617 7.6582336426 7.8558349609 8.0087280273 8.0357360840
 6.8066406250 5.7577514648 6.1254882813 7.1257019043 9.0142822266
 7.5854492188 9.9497985840 8.7576293945 6.7277526855 5.8448791504
 8.2864379883 7.4594116211 5.3176879883 8.4986877441 7.5239562988


Previous Page        Answer         Next Page         Home