title: A better alternative to using a long series of "if/else if" statements in C?
body: <p>Originally I used switch/case, but the condition had to be a constant value that the variable would match, versus a boolean of whether the variable was within the range.</p>
  
  <p>Instead, I have this monstrosity:</p>
  
  <pre><code>    if ( data[y] &gt; 91 ) {
         grades[9] = grades[9] + 1;
      }
      else if ( data[y] &gt; 88 &amp;&amp; data[y] &lt; 92 ) {
          grades[8] = grades[8] + 1;
      }
      else if ( data[y] &gt; 84 &amp;&amp; data[y] &lt; 89 ) {
          grades[7] = grades[7] + 1;
      }
      else if ( data[y] &gt; 81 &amp;&amp; data[y] &lt; 85) {
          grades[6] = grades[6] + 1;
      }
      else if ( data[y] &gt; 79 &amp;&amp; data[y] &lt; 82) {
          grades[5] = grades[5] + 1;
      }
      else if ( data[y] &gt; 74 &amp;&amp; data[y] &lt; 79 ) {
          grades[4] = grades[4] + 1;
      }
      else if ( data[y] &gt; 71 &amp;&amp; data[y] &lt; 75 ) {
          grades[3] = grades[3] + 1;
      }
      else if ( data[y] &gt; 68 &amp;&amp; data[y] &lt; 72 ) {
          grades[2] = grades[2] + 1;
      }
      else if ( data[y] &gt; 59 &amp;&amp; data[y] &lt; 69 ) {
          grades[1] = grades[1] + 1;
      else {
          //data[y] &lt; 60:
          grades[0] = grades[0] + 1;
      }
  </code></pre>
  
  <p>Does anybody know a nicer way to handle this block of code, since my switch/case idea can't apply? Surely there has to be a better way to do this.</p>