// This program generates random numbers between a and b #include #include // Needed for srand(), rand(), and RAND_MAX #include // Required for time() using namespace std; int main() { double a = 1.0, b = 5.0; double temp1, temp2; srand( time(NULL) ); for ( int i = 1; i <= 10; i++ ) { temp1 = double( rand() ) / RAND_MAX; // Random number in [0,1] temp2 = ( b - a ) * temp1 + a; // Random number in [a,b] cout << temp2 << endl; } cout << "\n\n"; system( "PAUSE" ); return( 0 ); }