title: While loop ends despite conditions not being met
body: <p>I am trying to write a code that keeps on asking for input until the sum of two consecutive numbers is a three-digit number, positive and even. For example (the words in bold are the input)</p>
  
  <p>Input? <strong>23</strong> Input? <strong>-21</strong> Input? <strong>120</strong> Input? <strong>-2</strong></p>
  
  <p>23 + −21 = 2 is not 3-digit; −21 + 120 = 99 is not 3-digit and not even. Then, 120 + −2 = 118 is 3-digit, positive, and even. So, program stops.</p>
  
  <p>However, I wrote a code like this, and after I typed the first two numbers the code ended, despite not being three-digit, positive nor even. What did I do wrong?</p>
  
  <pre><code>using namespace std;
  int main() {
      cout &lt;&lt; "Input? ";
      int a, b, c, sum;
      cin &gt;&gt; a;
      cout &lt;&lt; "Input? ";
      cin &gt;&gt; b;
      sum = a+b;
      while (sum&gt;=0) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
      }
      while (sum%2==1) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
      }
      while (sum&lt;100 &amp;&amp; sum&gt;999) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
      }
      return 0;
  }
  </code></pre>
  
  <p>Nvm, I forgot to change sum. However, there is still an issue. The code never ends, as it keeps on asking me for input. My new code:</p>
  
  <pre><code>using namespace std;
  int main() {
      int a, b, c, sum;
      cout &lt;&lt; "Input? ";
      cin &gt;&gt; a;
      cout &lt;&lt; "Input? ";
      cin &gt;&gt; b;
      sum = a+b;
      while (sum&gt;=0) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
          sum = a+b;
      }
      while (sum%2==1) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
          sum = a+b;
      }
      while (sum&lt;100) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
          sum = a+b;
      }
      while (sum&lt;999) {
          cout &lt;&lt; "Input? ";
          cin &gt;&gt; c;
          a=b;
          b=c;
          sum = a+b;
      }
      return 0;
  }
  
  </code></pre>