View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(){
	double a,x0,x1;
	scanf("%lf",&a);
	x0=a/2.0;
	x1=1/2.0*(x0+a/x0);
	while(fabs(x1-x0)>1e-5){
		x0=x1;
		x1=(x0+a/x0)/2.0;
	}
	printf("%.3lf",x1);
	return 0;
} 

Double click to view unformatted code.


Back to problem 74