title: Why can't i input second number (num2) when i input first one as alphabet?
body: <p>/<em>program to add two integers and if input is not integer print invalid output</em>/</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main()
  {
  int num1,num2,flag=0,sum;
  char chek,chek2;
  
  /* To check input value a integer or not*/
  
  if(scanf("%d%c", &amp;num1, &amp;chek);!= 2 || chek != '\n')
    { 
        flag=flag+1;
  
    }  
  if(scanf("%d%c", &amp;num2, &amp;chek2) != 2 || chek2 != '\n')
     { 
         flag=flag+1;
  
     }   
  if(flag!=0)
      printf("invalid input\n");
  else
   { 
       sum=num1+num2;
       printf("the sum is:%d",sum);
   }
   return 0;
  }
  </code></pre>