title: How to add up all the date leading to a specific date entered by the user?
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cmath&gt;
  using namespace std;
  int total(int month, int days, int years);
  bool leap();
  int numdays(int month, int years);
  
  int main()
  {
      int month;
      int days;
      int year;
      cout &lt;&lt; "Enter the Date like mm-dd-yyyy:\n";
      cin &gt;&gt; month &gt;&gt; days &gt;&gt; year;
      while (month &lt;= 0 || month &gt;= 13 || days &lt;= 0 || days &gt;= 32 || year &lt; 1000)
      {
          cout &lt;&lt; "You entered invalid information. Please re-enter date with a legitimate date:\n ";
          cin &gt;&gt; month &gt;&gt; days &gt;&gt; year;
      }
      total(month, days, year);
          return 0;
  }
  bool leap(int y)
  {
      if ((y % 4 == 0 &amp;&amp; y % 100 != 0) || (y % 400 == 0))
          return true;
  }
  int total(int m, int d, int y)
  {
      int total = 0;
      for (int i = 1; i &lt; m; i++)
          total = total + numdays(i, y);
      total = total + d;
      return total;
  }
  int numdays(int m, int y)
  {
      switch (m)
      {
      case 9:
      case 4:
      case 6:
      case 11:
          return 30;
      case 2:
          if (leap(y))
              return 29;
          else`enter code here`
              return 28;
      default:
          return 31;
      }
  }
  </code></pre>
  
  <p>The point of this code is to add up all the days in the year up to the specific day that the user enter. For some reason after I enter the date and such the code just stops running. I'm not sure if I'm calling the functions correctly or if I'm not sending the right data to the functions. If anyone can help that would be appreciated.</p>