title: Control may reach end of non-void function. C
body: <p>I am getting the above error on the return line of this code.</p>
  <pre><code>// Finds the length of the card number 
  int find_length(long long n)
  {
      int len;
      for (len = 0; n != 0; n /= 10, len++)
      return len;
  }
  </code></pre>
  <p>Full code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  #include &lt;unistd.h&gt;
  
  
  
  void print_credit_card_brand(long long ccn);
  bool check_validity(long long credit_card_number);
  int find_length(long long n);
  bool checksum(long long ccn);
  
  
  
  int main(void)
  {
      long long credit_card_number;
      do
      {
          credit_card_number = get_long_long(&quot;Enter valid credit card number without spaces or hyphens: &quot;);
      } while (credit_card_number &lt; 0);
  
      if (check_validity(credit_card_number) == true)
          print_credit_card_brand(credit_card_number);
      else
          printf(&quot;INVALID\n&quot;);
  }
  
  
  
  // Checks validity of credit card
  bool check_validity(long long credit_card_number)
  {
      int len = find_length(credit_card_number);
      return (len == 13 || len == 15 || len == 16) &amp;&amp; checksum(credit_card_number);
  }
  
  
  
  // Finds the length of the card number 
  int find_length(long long n)
  {
      int len;
      for (len = 0; n != 0; n /= 10, len++)
      return len;
  }
  
  
  
  // Determines validity using Luhn’s Algorithm
  bool checksum(long long ccn)
  {
      int sum = 0;
      for (int i =0; ccn != 0; i++, ccn /=  10)
      {
          if (i % 2 == 0)
               sum += ccn % 10;
          else
          {
              int digit = 2 * (ccn % 10);
              sum += digit / 10 + digit % 10;
          }
      }
      return (sum % 10) == 0;
  }
  
  
  
  // Prints results besed on length of credit card and 1st 2 digits
  void print_credit_card_brand(long long ccn)
  {
      if ( (ccn &gt;= 34e13 &amp;&amp; ccn &lt; 35e13) || (ccn &gt;= 37e13 &amp;&amp; ccn &lt; 38e13) )
          printf(&quot;AMEX\n&quot;);
      else if (ccn &gt;= 51e14 &amp;&amp; ccn &lt; 56e14)
          printf(&quot;MASTERCARD\n&quot;);
      else if ( (ccn &gt;= 4e12 &amp;&amp; ccn &lt; 5e12) || (ccn &gt;= 4e15 &amp;&amp; ccn &lt; 5e15) )
          printf(&quot;VISA\n&quot;);
      else
          printf(&quot;INVALID\n&quot;);
  }
  </code></pre>