title: Why is this while loop not ending in the code below?
body: <p>Sorry, this code seems silly but I just want to get the logic.</p>
  
  <p>I am trying to end the program when the user enters <code>quit</code> as an input. </p>
  
  <p>I wrote <code>name != "quit" &amp;&amp; sname != "quit"</code> as the while condition, so if any of them is <code>quit</code>, the loop would end (right?). </p>
  
  <p>But when I write <code>quit</code> as <code>name</code>, it still waits for <code>sname</code> input, if I write quit also for the <code>sname</code> input, then it finally ends. But shouldn't it end when it see <code>quit</code> for the very first time since I wrote the conditions with <code>&amp;&amp;</code>?</p>
  
  <p>In addition, I get the same output when I wrote the condition with <code>||</code>. Why is this so?</p>
  
  <pre><code>    int main()
      {
          string name="",sname="";
          cout &lt;&lt; "enter your name and surname \n";
  
              cout &lt;&lt; "&gt;&gt;name=";
              getline(cin,name);
  
              cout &lt;&lt; "&gt;&gt;surname=";
              getline(cin,sname);
  
         while (name != "quit" &amp;&amp; sname != "quit")
          {
              cout &lt;&lt; "&gt;&gt;name=";
              getline(cin,name);
  
              cout &lt;&lt; "&gt;&gt;surname=";
              getline(cin,sname);
          }
  
          return 0;
      }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>enter your name and surname
  &gt;&gt;name=John
  &gt;&gt;surname=Wick
  &gt;&gt;name=quit
  &gt;&gt;surname=
  </code></pre>