View Code of Problem 74

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

Double click to view unformatted code.


Back to problem 74