View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main()
  {
  	int a;
    	scanf("%d",&a);
    	float x1,x2;
    	x1=1.0;
    	x2=(x1+a/x1)/2.0;
    	while(fabs(x1-x2)>=1e-5)
        {
        	x1=x2;
          	x2=(x1+a/x1)/2.0;
        }
    	printf("%.3f\n",x2);
    	return 0;
  }

Double click to view unformatted code.


Back to problem 74