diff options
Diffstat (limited to 'ee1301/wk3/lab3/RtBab.cpp')
-rw-r--r-- | ee1301/wk3/lab3/RtBab.cpp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/ee1301/wk3/lab3/RtBab.cpp b/ee1301/wk3/lab3/RtBab.cpp deleted file mode 100644 index d75bd9e..0000000 --- a/ee1301/wk3/lab3/RtBab.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include <iostream> -#include <cmath> -using namespace std; - -double gennewGuess(double n, double old_guess) { - bool WA=true; - double real, old; - //if (WA) { - real=sqrt(n); - WA=false; - //} - double new_guess = ( old_guess + n / old_guess ) / 2; - old=new_guess; - if (((new_guess-real)/real)>0.01) { - cout << old << endl; - return gennewGuess(n, old); - } else { - cout << old << endl; - return new_guess; - } -} -int main () { - double temp, temp2; - cout << "Enter the Number to find square root: "; - cin >> temp; - if (temp<=0) { - cout << "Please enter a valid input(Positive Integer)." << endl; - return -1; - } - cout << "Guessing..." << endl; - double real=sqrt(temp); - temp2=temp; - temp = gennewGuess(temp, 1.0); - cout << "The Final Guess: " << temp << endl - << "Actual Value: " << real << endl; -} |