The problem is, basically, that if user enters a:5, b:f, everything works fine. But if it's the other way around and enters a letter to the 'a' variable, the program ends saying "Incorrect input", not letting the user to finish typing in rest of the variables. Why? Is it because of how I dealt with checking if the input is correct in the first place? How to "delay" the message and make it show after user finishes entering variables?
Here's the code:
#include <stdio.h>
int main(void) {
  short int l1=0, l2=0, l=0;
  int a=0, b=0;
  printf("Is number 'a' divisible by number 'b'?\n");
  printf("Number a: ");
  l1 = scanf("%d", &a);
  printf("Number b: ");
  l2 = scanf("%d", &b);
  l=l1+l2;
  if (l<2)
  {
  printf("Incorrect input");
  return 1;
  }
  else if (b==0)
    {
      printf("Operation not permitted");
      return 1;
    } 
    else if (a%b)
      {
        printf("%d is not divisible by %d", a, b);
      }
      else printf("%d is divisible by %d", a, b);
  return 0;
}
 
     
     
    