View Code of Problem 74

#include<bits/stdc++.h>
using namespace std;
int main(){
	double a,x0=1,x1;
	cin>>a;
	while(true){
		x1=(x0+a/x0)/2;
		if(fabs(x1-x0)<0.00001)
		break;
		x1=x0;
	}
	printf("%.3f",x1);
	return 0;
}

Double click to view unformatted code.


Back to problem 74