title: Is this the correct way of translating this math formula into a c function?
body: <p>I'm having some trouble with my functions and when I looked back over my code, I remembered that I wasn't too sure if I translated this math formula correctly. </p>
  
  <p>Note: If the parameters, x and y aren't in the interval [1, 20], then the function should return a -1.</p>
  
  <p><img src="https://i.stack.imgur.com/AMu9t.png" alt="enter image description here"></p>
  
  <p>Here's my code for that function:</p>
  
  <pre><code>double irrigationExposure(int x, int y) {
     double denominator, fraction, waterexp, wexp;
  
     if (x &gt;= 1 &amp;&amp; x &lt;= 20 &amp;&amp; y &gt;= 1 &amp;&amp; y &lt;= 20) {
        denominator = (1 + (abs(x - y)))* (1.0);
        fraction = ((IRRIEXPONUM)/(denominator));
  
        waterexp = (fraction) + (2);
  
        if (waterexp &lt;= 10) {
           wexp = waterexp;
        }
  
        else {
           wexp = 2.0;
        }
     }
  
     else {
        wexp = -1.0;
     }
  
     return wexp;
  }
  </code></pre>