title: Calculating day of year from date
body: <p>I need to calculate the day number of a given date. The year has 366 days in it. Each month however has a different value and I have to assign the values. Is there a quicker way to do it rather than the way I am going about it?</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main()
  {
     int day, month, year, dayNumber;
  
     cout&lt;&lt; "Please enter the month, by numerical value:";
     cin&gt;&gt; month;
     cout&lt;&lt;"Please enter the day, by numerical value:";
     cin&gt;&gt; day;
     cout&lt;&lt;"Please enter the year, by numerical value:";
     cin&gt;&gt; year;
     if (month == 1)
     {
        dayNumber= day;
        cout&lt;&lt; "Month;" &lt;&lt; '\t'&lt;&lt; month &lt;&lt; '\n'
            &lt;&lt; "Day:"&lt;&lt;'\t'&lt;&lt; day&lt;&lt; '\n'
            &lt;&lt; "Year:"&lt;&lt;'\t'&lt;&lt; year&lt;&lt;'\n'
            &lt;&lt; "Day Number:"&lt;&lt; '\t'&lt;&lt; dayNumber&lt;&lt; endl;
     }
     else if(month==2)
     {
        dayNumber= day+31; 
     }
  }
  </code></pre>