title: How to write following code without multiple if-else-statements using C++?
body: <p>Below are the conditions. How to write an equivalent code without using multiple if statements?</p>
  
  <pre><code>if ((direction &gt;= 0 &amp;&amp; direction &lt;= 11.25) || (direction &gt; 348.75 &amp;&amp; direction &lt;= 360)) {
      Dir = "N";
      } else if (direction &gt; 11.25 &amp;&amp; direction &lt;= 33.75) {
      Dir = "NNE";
      } else if (direction &gt; 33.75 &amp;&amp; direction &lt;= 56.25) {
      Dir = "NE";
      } else if (direction &gt; 56.25 &amp;&amp; direction &lt;= 78.75) {
      Dir = "ENE";
      } else if (direction &gt; 78.75 &amp;&amp; direction &lt;= 101.25) {
      Dir = "E";
      } else if (direction &gt; 101.25 &amp;&amp; direction &lt;= 123.75) {
      Dir = "ESE";
      } else if (direction &gt; 123.75 &amp;&amp; direction &lt;= 146.25) {
      Dir = "SE";
      } else if (direction &gt; 146.25 &amp;&amp; direction &lt;= 168.75) {
      Dir = "SSE";
      } else if (direction &gt; 168.75 &amp;&amp; direction &lt;= 191.25) {
      Dir = "S";
      } else if (direction &gt; 191.25 &amp;&amp; direction &lt;= 213.75) {
      Dir = "SSW";
      } else if (direction &gt; 213.75 &amp;&amp; direction &lt;= 236.25) {
      Dir = "SW";
      } else if (direction &gt; 236.25 &amp;&amp; direction &lt;= 258.75) {
      Dir = "WSW";
      } else if (direction &gt; 258.75 &amp;&amp; direction &lt;= 281.25) {
      Dir = "W";
      } else if (direction &gt; 281.25 &amp;&amp; direction &lt;= 303.75) {
      Dir = "WNW";
      } else if (direction &gt; 303.75 &amp;&amp; direction &lt;= 326.25) {
      Dir = "NW";
      } else if (direction &gt; 326.25 &amp;&amp; direction &lt;= 348.75) {
      Dir = "NNW";
  </code></pre>