title: Switch with scanf input
body: <p>I am tasked with writing a simple code using a while loop to test values and return the appropriate response to the values, in this case letter grades using a switch statement.</p>
  
  <p>My problem is testing for a value not inclusive of an integer. I believe I can solve the problem with a IF test prior to the switch statement. I am looking for help on phrasing this statement.</p>
  
  <p>I know that I am missing what I think is an assignment IF commend after the loop. I would also be open to the suggestion of how to check for an error and write and exception code to that error.</p>
  
  <p>Also if someone could be so kind, would you explain to me how the <code>scanf</code> works in terms of assigning a value from the input. I believe my problem lies in how <code>scanf</code> assigns values. I don't think my code is parsing a true value through the <code>switch</code> versus a temp value.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(void) {    
      int grades;
  
      printf("Enter a value for grading in numeric form\n");
  
      while ((scanf("%i", &amp;grades)) != EOF) {
          switch (grades) {
            case 10:
            case 9:
              printf("A grade of %i is an A\n", grades);
              break;
            case 8:
              printf("A grade of %i is an B\n", grades);
              break;
            case 7:
              printf("A grade of %i is an C\n", grades);
              break;
            case 6:
              printf("A grade of %i is an D\n", grades);
              break;
            case 5:
            case 4:
            case 3:
            case 2:
            case 1:
            case 0:
              printf("A grade of %i is an F\n", grades);
              break;                                                                                                  
            default:
              printf("This is not a valid entry\n");      
           }
       }
       return 0;
   }
  </code></pre>
  
  <p>I get an infinite loop error if trying to pass a character such as an A.</p>