View Code of Problem 74

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
#include<stdbool.h>
int main()
{
	int i, j;
	float x1, x2, a;
	x1 = 1.000;
	scanf("%f", &a);
	while (1)
	{
		x2 = (x1 + a / x1) / 2.0;
		if (x2 - x1 >= -0.00001&&x2 - x1 <= 0.00001)
			break;
		x1 = x2;
	}
	printf("%.3f", x1);
		return 0;
}

Double click to view unformatted code.


Back to problem 74