View Code of Problem 74

#include<bits/stdc++.h>
using namespace std;
int main() {
	double a=1,b;
	double x;
	cin>>x;
	b=(a+x/a)/2;
	while(fabs(b-a)>=0.00001){
		a=b;
		b=(a+x/a)/2;
	}
	cout<<fixed<<setprecision(3)<<b;
	return 0;
}

Double click to view unformatted code.


Back to problem 74