// test rand_float() // #include #include #include #include double rand_float(double a,double b) // from end of chapter4_7.c { return ((double)rand()/RAND_MAX)*(b-a) + a; } int main( void) { srand(time(0)); for( int i = 0; i < 10; ++i) { double d = rand_float( -5.5, 4.7); printf(" %g", d); } printf("\n"); return 0; } /* sample output: -2.94558 0.0458558 -4.05454 -1.39061 -4.07325 -4.00564 1.95799 -4.53035 3.77801 3.22975 */