title: How to calculate the true square root of a number with 3 user-defined functions
body: <p>I need a bit of help and some tips on where to go 
  For a programming assignment, I have to write a program that calculates the square root of the number that the user inputs and there are certain requirements. </p>
  
  <ol>
  <li><p>The <strong>main</strong> asks for the number and displays it, operates inside a Loop so that the user can repeat the program without closing it</p></li>
  <li><p>The calculation has to be done in a function called <strong>sqRoot</strong> which will be called by <strong>main</strong> using the algorithm:</p></li>
  </ol>
  
  <p>newValue = 0.5 * (oldValue + (X / oldValue))</p>
  
  <ol start="3">
  <li><strong>sqRoot</strong> will need to find the absolute value of the number with a function named <strong>absVal</strong> which will then be called by <strong>sqRoot</strong></li>
  </ol>
  
  <p>I dont even know where to start with a program like this. But, this is what i have so far:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cmath&gt;
  #include &lt;cstdlib&gt;
  using namespace std;
  
  double sqRoot();
  double absVal();
  int i = 0;
  double X;
  
  int main()
  {
     sqRoot = sqrt(X);
     double X;
  
     // Calculations
  
     cout &lt;&lt; "Please enter a number: ";
     cin &gt;&gt; X;
  
     while (X &lt;= 0)
     {
        cout &lt;&lt; "*** Error: Invalid Number! *** " &lt;&lt; endl;
        cout &lt;&lt; "Please enter a number: ";
        cin &gt;&gt; X;
     }
     while (X &gt;= 1)
     {
        cout &lt;&lt; "The Square Root is: " &lt;&lt; sqRoot &lt;&lt; endl;
     }
  }
  
  double sqRoot ()
  {
     double newValue;
     double oldValue ;
     while (abs(newValue - oldValue) &gt; 0.0001)
     {
        newValue = 0.5 * (oldValue + ( X / oldValue));
        oldValue = newValue;
        cout &lt;&lt; " The square root is: " &lt;&lt; newValue &lt;&lt; endl;
     }
     return (newValue);
  }
  </code></pre>
  
  <p>I'm just stuck with what to do next and how to properly write the program.
  Thank You for the help and tips!</p>