title: Zeller's congruence coding, outputing wrong day
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std; 
  
  
  void dayofweek(int &amp;m, int d, int y);
  int main()
  {
  
  int m, d, y, daynum; 
  char ans;
  
  do {
  cout &lt;&lt; "Enter a date as mm dd yyyy: \n";
  cin &gt;&gt; m &gt;&gt; d &gt;&gt; y; 
  
  dayofweek(m, d, y);
  
  cout &lt;&lt; m &lt;&lt; d &lt;&lt; y;
  
  daynum=(d + 5 + ((26*(m+1))/10) + ((5*(y%100))/4) + ((21*(y/100))/4) )%7;
  
  cout &lt;&lt; daynum;
  
  
  switch(daynum)
  {
      case 0:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Monday \n";  
          break;
      case 1:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Tuesday \n"; 
          break; 
      case 2:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Wednesday \n";
          break;
      case 3:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Thursday \n";
          break;
      case 4:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Friday \n";
          break;
      case 5:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Saturday \n";
          break;
      case 6:
          cout &lt;&lt; m &lt;&lt; "/" &lt;&lt; d &lt;&lt; "/" &lt;&lt; y &lt;&lt; "is a Sunday \n";
          break;
  }
  cout&lt;&lt;"Do you want to continue? (y/n) \n"; 
  cin &gt;&gt; ans; 
  }while (ans == 'y' || 'Y');
  return 0;
  }
  
  void dayofweek(int&amp; m, int d, int y) 
  {
      if (m==1 || m==2)
      m=m+12;
  
  }
  </code></pre>
  
  <p>This compiles and works fine, but when I input dates, the wrong weekday comes up. </p>
  
  <p>For example, 2/28/2014 is a Friday, but Saturday comes up.
  Any suggestions? I am stuck on what to change, I checked the equations many times as well. </p>