title: Control may reach end of non-void function [-Werror,-Wreturn-type]
body: <p>I am having a slight problem regarding functions. I believe it is likely because I am not using them properly. My code is as follows:</p>
  
  <pre><code>int duration(string fraction)
  {
      // X part of the fraction
      int numerator = fraction[0];
      // Y part of the fraction
      int denominator = fraction[2];
      // Checking for eighth note, quarter note and half note
      if (numerator == 1)
      {
          switch (denominator)
          {
              case 8:
              return 1;
              case 4:
              return 2;
              case 2:
              return 4;
         }
      }
      // Checking for dotted quarter note
      else
          return 3;
  }
  </code></pre>
  
  <p>What's the problem in my code that I'm getting this particular error:</p>
  
  <p>error: control may reach end of non-void function
        [-Werror,-Wreturn-type]</p>