WenhaoCui_6153876930_HW1_Q1

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> #include <cmath> using namespace std; double mySqrt(double x){ double estimate = 1; double newEstimate = 0.5*(estimate + x/estimate); while (abs(newEstimate-estimate)>0.000001){ estimate = newEstimate; newEstimate = 0.5*(estimate + x/estimate); } return estimate; } int main() { double s = mySqrt(5); cout << s << endl; // expect 2.236 return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines