# include<stdio.h> # include<math.h> int main(void) { float x; float x1,x2 = 3; scanf("%f",&x); while(fabs(x2-x1)>1e-5) { x1 = x2; x2 = 0.5*(x1+x/x1); } printf("%.3f",x2); return 0; }
Double click to view unformatted code.