title: returning a float value when writing a function in C
body: <p>I am writing a simple function in c that will return the middle of 2 float values.</p>
  
  <p>My function looks like this:</p>
  
  <pre><code>float mid(float a, float b) {
        return (a + b)*0.5; 
  }
  </code></pre>
  
  <p>The problem is that this function will always produce 0.000000. I am checking this by using:</p>
  
  <pre><code>printf("%f", mid(2,5))
  </code></pre>
  
  <p>this will print 0.000000.</p>
  
  <p>However, if i just do:</p>
  
  <pre><code>printf("%f", (2+5)*0.5) 
  </code></pre>
  
  <p>this will print 3.5, which is correct.</p>
  
  <p>How do I fix this problem?</p>