title: Return number of days in a given month of a given year
body: <p>I wrote a program that, given the month number and the year, returns the number of days in that month:</p>
  
  <pre><code>#include &lt;iostream.h&gt;
  #include &lt;conio.h&gt;
  void main() {
    clrscr();
    int month, year, i;
    cout &lt;&lt; "give the year \n";
    cin &gt;&gt; year;
    cout &lt;&lt; "give the month\n";
    cin &gt;&gt; month;
    for (i = 1; i &lt;= 12; i++) {
      i = month;
      switch (month) {
        case 1:
          cout &lt;&lt; "number of day in month is 31\n";
          break;
        case 2:
          if (year % 4 == 0) {
            cout &lt;&lt; "the number of days is 29 \n";
          } else {
            cout &lt;&lt; "the number of days is 28 \n";
          }
          break;
        case 3, 5, 7, 8, 10, 12:
          cout &lt;&lt; "the number of days is 31 \n";
          break;
        default:
          cout &lt;&lt; "the number of days is 30 \n";
          return;
      }
    }
    return;
  }
  </code></pre>
  
  <p>When I give the month number <code>3</code>, it returns <code>the number of days is 31</code>, so it works fine. But when I give <code>1</code> or <code>2</code>, the output is</p>
  
  <pre><code>number of day in month is 31
  number of day in month is 31
  number of day in month is 31
  .
  .
  .
  .
  </code></pre>
  
  <p>How can I make it return only <code>number of day in month is 31</code> or <code>number of day in month is 28</code> if the case is <code>2</code>?</p>