View Code of Problem 74

#include<stdio.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	double x[10];
	x[1]=1.000;
	int i;
	for( i=1;i<10;i++){
		x[i+1]=(x[i]+n/x[i])/2.0;
		if(fabs(x[i]-x[i+1])<(1e-5)){
			break;
		}
	}
	printf("%.3f",x[i]);
	
	return 0;
} 

Double click to view unformatted code.


Back to problem 74