View Code of Problem 74

#include<bits/stdc++.h>
using namespace std;
int main() {
	double xn, xn2, a;
	cin>>a;
	xn2=a/2.0;
	while(fabs(xn-xn2)>=0.00001) {
		xn=xn2;
		xn2=(xn+a/xn)/2;
	}
	printf("%.3f", xn2); 
}

Double click to view unformatted code.


Back to problem 74