View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(){
	float a;
	scanf("%f",&a);
	float x[100];
	x[0]=a/2;
	x[1]=(x[0]+a/x[0])/2;
	int i=1;
	while(fabs(x[i]-x[i-1])>=0.00001) {
		i++;
		x[i]=(x[i-1]+a/x[i-1])/2;
	}
	printf("%.3f\n",x[i]);
}

Double click to view unformatted code.


Back to problem 74