title: make a loop reject all non integer inputs and integer inputs outside of range (C programming)
body: <p>trying to make loop that will reject non integer inputs as well
  my code works to print invalid input and loop whenever a answer outside of the range is inputted but it will keep looping forever if a non integer is entered, is there any way to program it so that it will print invalid and loop back?</p>
  <p>my code:</p>
  <pre><code>while(ans &lt; 1 || ans &gt; 4)
      {
          printf(&quot;\n\nEnter the ans: &quot;);
          scanf(&quot;%f&quot;, &amp;ans); 
          if(ans &lt; 1 || ans &gt; 4)
              printf(&quot;Invalid Input! Please re-enter value.\n&quot;);
      }
  </code></pre>