title: How to prevent non-numeric input in C?
body: <p>I wrote a small C program which will get an input from the user and check if the input is even or odd.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main()
  {
      int n;
      printf("Enter an integer number: ");
      scanf("%d",&amp;n);
  
      if(n%2 == 0)
      {
          printf("\n%d is an EVEN number.\n",n);
      }
      else
          printf("\n%d is an ODD number.\n",n);
  
       return 0;
  }
  </code></pre>
  
  <p>but when I enter an alphabet or a symbol, it shows the output as 0 and says input is EVEN. How can I prevent user from entering alphabets and symbols? What's the easiest way to do that?</p>