View Code of Problem 74

#include<stdio.h>
#include<math.h>
void main() {
	double a,x1,x2=1.0;
	scanf("%lf",&a);
	for(;;) {
		x1=x2;
		x2=(x1+a/x1)/2.0;
		if(fabs(x1-x2)<0.00001) {
			printf("%.3lf\n",x2);
			break;
		}
	}
}

Double click to view unformatted code.


Back to problem 74