title: Incrementing in C++ - Help understanding sample program output
body: <p>I am currently learning C++ and I like to read and explore programs I find on the internet. </p>
  
  <p>I have found this example C++ code, which gives "4 is greater than 2" as an output, but I cannot figure out why:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define MAX( a, b ) ( a &gt; b ) ? (a) : (b)
  
  int main()
  {
      int x = 2, y = 2;
  
      if( MAX( ++x, y ) == x )
      {
          printf( " %d is greater than %d ", x, y );
      }
  
      return 0;
  }
  </code></pre>
  
  <p>What I do not understand is: if you look at the segment which states</p>
  
  <pre><code>if( MAX( ++x, y ) == x )
  </code></pre>
  
  <p>it is supposed to increase the X variable by 1, then call MAX; at that point X should be 3. Instead, when you compile it the output is as aforementioned.</p>
  
  <p>I have done some research on how the ++ operator works ( <a href="https://stackoverflow.com/questions/1812990/incrementing-in-c-when-to-use-x-or-x">Incrementing in C++</a> ) but I could not get the solution anyway. Could you please explain me why this happens?</p>
  
  <p>Thanks in advance for your help.</p>