title: sqrt function in C not returning exact value
body: <p>My code is as follows:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  int distance(int x1, int y1, int x2, int y2){
      double value = sqrt(pow((double)(x2- x1),2.0) + pow((double)(y2 - y1),2.0));
      return value;
  }
  int main(void){
      int A_x, A_y, B_x, B_y, C_x, C_y;
      printf(&quot;Enter 1st point:&quot;);
      scanf(&quot;%d&quot;, &amp;A_x);
      scanf(&quot;%d&quot;, &amp;A_y);
      printf(&quot;Enter 2nd point:&quot;);
      scanf(&quot;%d&quot;, &amp;B_x);
      scanf(&quot;%d&quot;, &amp;B_y);
      printf(&quot;Enter 3rd point:&quot;);
      scanf(&quot;%d&quot;, &amp;C_x);
      scanf(&quot;%d&quot;, &amp;C_y);
      double AB = distance(A_x, A_y, B_x, B_y);
      printf(&quot;%.2lf&quot;, AB);
      // double powered = pow((double)(A_x- B_x),2.0) + pow((double)(A_y - B_y),2.0);
      // double squared = sqrt(powered);
      // printf(&quot;%.2lf&quot;, squared);
      double BC = distance(B_x, B_y, C_x, C_y);
      printf(&quot;%.2lf&quot;, BC);
      double CA = distance(C_x, C_y, A_x, A_y);
      printf(&quot;%.2lf&quot;, CA);
      if(AB+BC&gt;CA &amp;&amp; AB+CA&gt;BC &amp;&amp; BC+CA&gt;AB){
          double perimeter = AB+BC+CA;
          printf(&quot;Perimeter of triangle = %.2lf&quot;,perimeter);
          return 0;
      }else{
          printf(&quot;Invalid traingle&quot;);
          return -1;
      }
      
  }
  </code></pre>
  <p>I am getting the following in the compiler:</p>
  <p><a href="https://i.stack.imgur.com/gUnrx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUnrx.png" alt="enter image description here" /></a></p>
  <p>I am not exactly sure why I'm getting 2.00 for AB instead of 2.83. Would be glad if someone could explain where I went wrong :)</p>