title: How to tally the expression with operator precedence table in C?
body: <p>I know the following code is not a good way to write expressions in C and there might be a lot of post already discouraging such post, but I am sure the output is not compiler dependent.</p>
  <p>Here is what the code looks like:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int main() {
      int x = 2;
      int y = 1;
      int z = x || ++y;
      
      printf(&quot;%d %d %d\n&quot;, x, y, z);
      return 0;
  }
  </code></pre>
  <p>I have the following questions:</p>
  <ol>
  <li><p>Now in this I know that short-circuiting would happen and <code>++y</code> is never evaluated but if I am not wrong, unary operators have higher precedence than logical operator and hence <code>++y</code> should happen first and the expression should short circuit from the reverse direction right?</p>
  </li>
  <li><p>Also one more issue is that if the short-circuit starts happening from the left side, then <code>x</code> is evaluated first and then because of short-circuiting, the value of x should be assigned to <code>z</code>, but it is getting answer to be 1. Why so?</p>
  </li>
  </ol>