View Code of Problem 74

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<malloc.h>

int main(){
	float x1, x2, a;
	scanf("%f", &a);
	x1 = 1;
	do {
		x2 = x1;
		x1 = (x1 + a / x1) / 2;
	} while (fabs(x1 - x2) >= 0.00001);
	printf("%.3f\n", x1);

}

Double click to view unformatted code.


Back to problem 74