title: C Program to Calculate Hypotenuse
body: <p>I'm fairly new to coding and am currently learning C. In class I was given an assignment to write a program that calculates the hypotenuse of the triangle by using our own functions. However, there seems to be something wrong with the code that I have written.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  double hypotenuse(double x, double y, double z);
  
  int main(void) {
      double side1, side2, side3, counter;
  
      side3 = 1;
  
      for (counter = 0; counter &lt;= 2; counter++) {
          printf("Enter values for two sides: ");
          scanf_s("%d %d", &amp;side1, &amp;side2);
  
          printf("%.2f\n", hypotenuse(side1, side2, side3));
      }
  
      return 0;
  }
  
  double hypotenuse(double x, double y, double z) {
      x *= x;
      y *= y;
      z = sqrt(x + y);
  
      return z;
  }
  </code></pre>
  
  <p>My instructor said that we're allowed to use the square root function <code>sqrt</code> of the math library. The main errors that I'm facing are:</p>
  
  <p>1) <code>side3</code> is not defined (This is why I just arbitrarily set it to 1, but is there some other way to prevent this error from happening?)<br>
  2) If I, for example, inputted 3 and 4 as <code>side1</code> and <code>side2</code>, then <code>side3</code> should be 5. However, the printed result is an absurdly long number.</p>
  
  <p>Thank you for the help! Any words of advice are appreciated.</p>