View Code of Problem 74

#include<stdio.h>
int main(){
	int x;
	scanf("%d",&x);
	float x1,x2;
	x1 = (float)x / 2;
	x2 = (x1 + (float)x / x1) / 2;
	while((x1 - x2) > 0.00001){
		x1 = x2;
		x2 = (x1 + (float)x / x1) / 2;
	}
	printf("%.3f\n",x2);
	return 0;
}

Double click to view unformatted code.


Back to problem 74