View Code of Problem 74

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

Double click to view unformatted code.


Back to problem 74