View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main()
{
	int i=0,j,k,n,sum=0;
	double a[10000];
	scanf("%d",&n);
	a[0]=n;
	do
	{
		a[i+1]=1/2.0*(a[i]+n/a[i]*1.0);
	//	printf("%lf",a[i]);
		i++;
	}while(fabs(a[i]-a[i-1])>0.00001);
	printf("%.3lf",a[i]);
}

Double click to view unformatted code.


Back to problem 74