title: how to stop this code from hanging at wrong inputs?
body: <p>I am learning C from ' programming in C' by Stephen Kochan. I am working on exercise no 4 of chapter 6 , writing a code that acts as a simple accumulator calculator. code is following. it works fine as long as inputs are provided in the right manner order. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
      int main(void)
      {
          float num, accum = 0;
  
          char operator;
  
  
          while(1)
  
          {
  
            printf("Enter the number and the operator ");
            scanf("%f %c",&amp;num, &amp;operator);
  
            if (operator == 'E') break;
  
            switch (operator){
  
          case 'S':
            accum = num;
            printf("= %g\n",accum);
            break;
  
          case '+':
            accum = accum + num;
            printf("= %g\n",accum);
            break;
  
          case '-':
            accum = accum - num;
            printf("= %g\n",accum);
            break;
  
          case '*': 
            accum = accum * num;
            printf("= %g\n",accum);
            break;
  
          case '/':
            accum = accum / num;
            printf("= %g\n",accum);
            break;
            }      
          }
  
          printf("= %g\n",accum);
          printf("End of Calculation\n");
  
        return 0;
  
      }
  </code></pre>
  
  <p>but it hangs on the wrong inputs. what can be done to check such behaviour?</p>