View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(){
    double x1,x2,n;
    scanf("%lf",&n);
    x1=1;
    x2=1.00/2.00*(x1+n*1.00/x1);
    while (fabs(x2-x1)>=0.00001){
        x1=x2;
        x2=1.00/2.00*(x1+n*1.00/x1);
    }
    printf("%.3f",x2);
}

Double click to view unformatted code.


Back to problem 74