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