title: Infinite for loop in C++
body: <p>While I am reading in a code, I found that the loop for was used with just two arguments (the one in the middle is absent). When the program is executed, the loop for is infinite. Here is a minimal working environment. Could anyone tell what is wrong in the code?</p>
  
  <pre><code>// Example program
  #include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
    for (int i = 0; ; i = (i+1)%2)
    {
        cout &lt;&lt; i &lt;&lt; endl;
        }
  }
  </code></pre>