title: Infinite loop occurs when indexing an array
body: <pre><code>int main()
  {
      int i;
      int vals[5];
  
      for (i = 0; i &lt;= 5; i++)
      {
          vals[i] = 0;
      }
  
      printf("%d\n", i);
      return 0;
  } 
  </code></pre>
  
  <p>I'm trying to learn C from a university tutorial. They mentioned that in the above code:</p>
  
  <p>The for loop is reset when <code>i</code> reaches 5, and the program goes through the loop again, and again, repeatedly.</p>
  
  <p>I couldn't understand why and I tried to figure it out in the <a href="http://pythontutor.com" rel="nofollow noreferrer">pythontutor.com</a>, it prints <code>6</code> (It's experimental now for C.) What's the proper output and why this occurs?</p>