View Code of Problem 74

#include<bits/stdc++.h>
using namespace std;
int main()
{
	double x; 
	cin>>x;
	double pre=x,temp=(pre+x/pre)/2;
	while(abs(temp-pre)>=0.00001)
	{
		pre=temp;
		temp=(pre+x/pre)/2;
	}
	printf("%.3lf",pre);
}

Double click to view unformatted code.


Back to problem 74