View Code of Problem 74

#include<stdio.h>
#include <string.h>
#include <math.h>
int main(){
	double x0,x1;
	double a;
	int i,j;
	scanf("%1f",&a);
	x0=a/2;
	x1=(x0+a/x0)/2;
	while(abs(x1-x0)>=0.00001){
		x0=x1;
		x1=(x0+a/x0)/2;
	}
	printf("%.3f",x1);
	
	printf("\n");
	return 0;
}

Double click to view unformatted code.


Back to problem 74