converting an if, else if, else statement into a switch statement in c++
<p>I wanted to know if I could convert the following if else statement into a switch statement in c++. If I can could someone please tell me how, as currently I am getting errors the way I have written it. </p>

<p>This is the if else statement i am trying to convert into a switch statement.</p>

<pre><code>if ( t&gt;=10 &amp;&amp; t &lt;=18 ) {
        blue=0; green=1; red=1;
        xb_led=0; xg_led=1; xr_led=1;

    } else if ((t &gt;18 &amp;&amp; t&lt;=22)||(t&gt;22 &amp;&amp; t&lt;=25)) {
        green=0; blue=1; red=1;
        xg_led=0; xb_led=1; xr_led=1;
    } else {
        red=0; green=1; blue=1;
        xr_led=0; xg_led=1; xb_led=1;
    } 
</code></pre>

<p>This is what I have converted it to but I get an error.</p>

<pre><code>switch(t) {

        case t &gt;=10 &amp;&amp; t&lt;=18:
        blue=0; green=1; red=1;
        xb_led=0; xg_led=1; xr_led=1;
        break;

        case t &gt;18 &amp;&amp; t&lt;=22|| t&gt;22 &amp;&amp; t&lt;=25:
        green=0; blue=1; red=1;
        xg_led=0; xb_led=1; xr_led=1;
        break;

        case t &gt;25:
        red=0; green=1; blue=1;
        xr_led=0; xg_led=1; xb_led=1;
        break;             

    }
</code></pre>