title: Count not updating in nested for-loop
body: <p>I have a program that is meant to count a number of days that a Monday occurs in a specific range. I am having trouble updating the count through each iteration. I tried changing up the count methods even putting it in some if loops to no effect.</p>
  <p><strong>Current Code</strong></p>
  <pre><code>#include &lt;stdio.h&gt;
  
  #define SIZE 1000
  
  #include &quot;printVday.h&quot;
  
  int main() {
      //update date opposite of year so go through all the days first then the year
      //while loop that checks if the date was on a Monday and gets all the Mondays from the month then checks the second last one 
      int d = 15, m = 5, y, day, month, year, yearplus, i = 0;
      char dates[SIZE];
  
      printf(&quot;Enter a year: &quot;);
      scanf(&quot;%d&quot;, &amp;y);
      
      for (year = y; year &lt;= y + 20; year++) {
          i++;
          for (day = 15; day &lt;= 24; day++) {
              int dow = weekday(day, m, year);
              if (dow == 1) {
                  printf(&quot;\n%d /%d /%d count = %d\n&quot;, day, m, year, i);
                  i = 0;
              }
          }
      }
      return 0;
  }
  
  int weekday(int d, int m, int y) {
  
      return (d += m &lt; 3 ? y-- : y - 2, 23 * m / 9 + d + 4 + y / 4 - y / 100 + y / 400) % 7; //Michael Keith and Tom Craver expression to minimise number of keystrokes for conversion of a gregorian date into numerical day of week. Algorithm invented by John H. Conway
  
  }
  </code></pre>
  <p><em>Currently my count is updating but not properly</em></p>
  <p><strong>Current Input &amp; Output</strong></p>
  <pre><code>Enter a year: 2015
  
  18 /5 /2015 count = 1
  
  16 /5 /2016 count = 1
  
  23 /5 /2016 count = 0
  
  15 /5 /2017 count = 1
  
  22 /5 /2017 count = 0
  
  21 /5 /2018 count = 1
  
  20 /5 /2019 count = 1
  
  18 /5 /2020 count = 1
  
  17 /5 /2021 count = 1
  
  24 /5 /2021 count = 0
  
  </code></pre>
  <p><em>... all the way to 2035</em></p>
  <p><strong>Desired Output</strong></p>
  <pre><code>18 /5 /2015 count = 1
  
  16 /5 /2016 count = 2
  
  23 /5 /2016 count = 0
  
  15 /5 /2017 count = 2
  
  22 /5 /2017 count = 0
  
  21 /5 /2018 count = 1
  
  20 /5 /2019 count = 1
  
  18 /5 /2020 count = 1
  
  17 /5 /2021 count = 2
  
  24 /5 /2021 count = 0
  </code></pre>
  <p>If there is just one day in the specified range that happens to land on a Monday then it will count as 1... if there are 2 days that happen to land on a Monday in the specified range the first instance will be counted as 2 while the latter is updated to 0.</p>