title: Operator precedence and evaluation order
body: <p>I can't understand output of this program:</p>
  
  <pre><code>#include&lt;iostream&gt;
  using namespace std;
  int main()
  {
      int x = 1 , y = 1, z = 1;
      cout &lt;&lt; ( ++x || ++y &amp;&amp; ++z ) &lt;&lt; endl; //outputs 1;
      cout &lt;&lt; x &lt;&lt; " " &lt;&lt; y &lt;&lt; " " &lt;&lt; z ;  //x = 2 , y = 1 , z = 1;
      return 0;
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>1
  2 1 1
  </code></pre>
  
  <p>If <code>||</code> is evaluated first then this output is fine, however <a href="https://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B#Operator_precedence" rel="nofollow">this</a> article says that <code>&amp;&amp;</code> has a higher precedence than <code>||</code>, and thus it must be evaluated first. If this is the case then according to me output should be:</p>
  
  <pre><code>1
  1 2 2
  </code></pre>
  
  <p>as <code>++y &amp;&amp; ++z</code> would evaluate to <code>true</code> and thus <code>++x</code> won't be evaluated. </p>