If statement condition operators
<p>I was trying to look up on to some basics i stumbled on this problem where I was required to give a condition and print a statement based on whether the number was odd or even.</p>

<p>Here's the first code : <a href="https://ideone.com/vS8wgs" rel="nofollow">https://ideone.com/vS8wgs</a></p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main() {



  int x = 18;


   if(x%2 == 0 &amp;&amp; 2&lt;=x&lt;=5){

    cout &lt;&lt; "x lies between 2 and 5" &lt;&lt; endl;

   }
   if(x%2 == 0 &amp;&amp; 6&lt;=x&lt;=20){

    cout &lt;&lt; "x lies between 6 and 20" &lt;&lt; endl;

   }

    return 0;
}
</code></pre>

<p>Answer to the first one turns out to be :</p>

<pre><code>x lies between 2 and 5
x lies between 6 and 20
</code></pre>

<p>Here the second variant : <a href="https://ideone.com/rQ7KoW" rel="nofollow">https://ideone.com/rQ7KoW</a></p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main() {


int x =18;

 if(x%2 == 0 &amp;&amp; x &gt;= 2 &amp;&amp; x &lt;=5){

    cout &lt;&lt; "x lies between 2 and 5" &lt;&lt; endl;

   }

   if(x%2 == 0 &amp;&amp; x &gt;= 6 &amp;&amp; x&lt;=20){

    cout &lt;&lt; "x lies between 6 and 20" &lt;&lt; endl;

   }

    return 0;
}
</code></pre>

<p>Answer to the Second one turns out to be :</p>

<pre><code>x lies between 6 and 20
</code></pre>

<p>Up until now i was assuming both would return the same result, I would like to know the reason for both not having same functionality. </p>