title: C++ Boolean evaluation
body: <p>So I'm curious as to why this happens.</p>
  
  <pre><code>int main()
  {
     bool answer = true;
     while(answer)
     {
        cout &lt;&lt; "\nInput?\n";
        cin &gt;&gt; answer;
     }
  return 0;
  }
  </code></pre>
  
  <p>Expected behavior:
  0 - Exits program,
  1 - Prompts again,
  Any non-zero integer other than 1 - Prompts again</p>
  
  <p>Actual behavior:
  0 - As expected,
  1 - As expected,
  Any non-zero integer other than 1 - Infinite loop</p>
  
  <p>From <a href="http://www.learncpp.com/cpp-tutorial/26-boolean-values/" rel="noreferrer">http://www.learncpp.com/cpp-tutorial/26-boolean-values/</a></p>
  
  <pre><code>One additional note: when converting integers to booleans, 
  the integer zero resolves to boolean false, 
  whereas non-zero integers all resolve to true.
  </code></pre>
  
  <p>Why does the program go into an infinite loop?</p>