blob: d60bedabbaf7aff06d082a462d3ed7be37121070 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <iostream>
#include <cmath>
using namespace std;
double genNewGuess(double n, double oldGuess); {
New=(oldGuess+n/oldGuess)/2;
oldGuess=New;
return New;
}
int main () {
double temp;
cout << "Enter the Number to find square root: ";
cin >> n;
if (n==0) {
cout << "Nah fam." << endl;
return -1
}
cout << "Guessing..."
double real=sqrt(n);
do {
} (while abs(New-real)/real<0.1)
}
|