title: Square root program in C without using sqrt function
body: <p>I am trying to make a program in C to find the approximate square root of a number using the formula NG = 0.5( LG + N/ LG). So far i have:</p>
  
  <pre><code>#include &lt;stdio.h&gt; 
  #include &lt;math.h&gt; 
  int main(){
      double n;
      double LG=1;
      double NG;
      printf("Enter number");
      scanf_s("%lf",&amp;n);
      do{
          NG=(.5*(LG+n/LG));
          LG=NG;
      }while((NG*NG-n)&lt;.005);
      printf("The root is %lf",NG);
  }
  </code></pre>
  
  <p>This structure works fine in java, but the loop doesn't seem to be executing in C.</p>
  
  <p>Thanks for any advice.</p>