#include <stdio.h> #include <math.h> int main() { float X; float a; scanf("%f",&a); X = a/2; float b; while(fabs(b-X)>=0.00001) { b = X; X = (X+a/X)/2; } printf("%.3f",X); }
Double click to view unformatted code.