This preview shows page 1. Sign up to view the full content.
Unformatted text preview: guess = rand() / static_cast<double>(RAND_MAX) ; // scale to range [0, (upper-lower)] guess = guess * (upper - lower) ; // move to range [lower, upper] guess = guess + lower ; cout << "Guess is " << guess << endl ; if ( guess*guess > n ) upper = guess ; else lower = guess ; } // lower <= square-root(n) <= upper // and upper - lower <= accuracy cout << "The square root of " << n << " is between " << lower << " and " << upper << "." << endl ; }...
View Full Document
This note was uploaded on 10/28/2010 for the course CSCI 1113 taught by Professor Staff during the Spring '08 term at Minnesota.
- Spring '08