View Code of Problem 74

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    double a,x1=1,x2;
    scanf("%lf",&a);
    while(1){
        x2=(x1+a/x1)/2;
        if(fabs(x2-x1)<0.00001){
            printf("%.3lf\n",x2);
            break;
        }
        x1=x2;
    }
	return 0;
}

Double click to view unformatted code.


Back to problem 74