View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(){
  double n;
  double x0=1.0;
  double x1=1.0;
  scanf("%lf",&n);
 
  while(1)
    {
        x0=x1;
        x1=(x0+n/x0)/2;
 
        if(fabs(x1-x0)<0.00001)
        {
            printf("%.3f",x1);
            break;
        }
    }
 
 
  return 0;
}

Double click to view unformatted code.


Back to problem 74