View Code of Problem 74

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main() {
	int x;
	scanf("%d",&x);
	double x2,x1=1.0;
	x2=(x1+x/x1)/2.0;
	while(fabs(x2-x1)>0.00001){
		x1=x2;
		x2=(x1+x/x1)/2.0;
	}
	printf("%.3lf",x2);
}

Double click to view unformatted code.


Back to problem 74