title: How does the while loop work here?
body: <p>The following code I came across though I have basic idea of C. I still get the logic of below code.</p>
  
  <ol>
  <li><p>How does the loop terminate and when does the loop terminate — at what condition?</p></li>
  <li><p>At last <code>counter</code> becomes zero, but why doesn't the loop continue to execute with -1, -2 and instead it terminates?</p></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void func(void);
  static int count = 5;
  int main()
  {
      while (count--)
      {
          func();
      }
      return 0;
  }
  
  void func(void)
  {
      static int i = 5;
      i++;
      printf("i is %d and count is %d\n", i, count);
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>i is 6 and count is 4
  i is 7 and count is 3
  i is 8 and count is 2
  i is 9 and count is 1
  i is 10 and count is 0
  </code></pre>