View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(void){
	double x1,x0;
	int n;
	scanf("%d",&n);
	x0=n/2;
	x1=(x0+n/x0)/2;
	do{
		x0=x1;
		x1=(x0+n/x0)/2;
	}while(fabs(x1-x0)>=1e-5);
	printf("%.3lf",x1);
}

Double click to view unformatted code.


Back to problem 74