View Code of Problem 74

#include<iostream>
#include<cmath>
using namespace std;

int main(void)
{
  double x,sx1,sx2;
  cin>>x;
  sx1=0;sx2=1;
  while(abs(sx1-sx2)>=0.00001)
  {
    sx1=sx2;
    sx2=(sx1+x/sx1)/2.0;
  }
  printf("%.3lf",sx2);
}

Double click to view unformatted code.


Back to problem 74