title: How to debug this error in C: function definition is not allowed here?
body: <p>I am new to programming and am taking edX's CS50 (Intro to Programming) class. There is this C code that I have been trying to compile, but always results in an error message that looks like this:
  <a href="https://i.stack.imgur.com/Kxeqw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Kxeqw.png" alt="error message"></a></p>
  
  <p>This is the code lines that I have been trying to compile:</p>
  
  <pre><code>#include &lt;cs50.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  int main (void)
  {
     bool valid_triangle (float a, float b, float c);
     bool valid_triangle (float a, float b, float c)
    {
     // check positive values
       if ( a &lt;= 0 || b &lt;= 0 || c &lt;= 0 )
      {
      return false;
       }
      //check two sides are longer
      if ( (a + b &lt;= c) || (a+c &lt;= b) || (b+c &lt;= a))
      {
      return false;
      }
  
      //otherwise return true
       return true;
   }
  
  }
  </code></pre>
  
  <p>Does anyone know what I did wrong and how to fix this error? Thanks a lot!</p>