With this code, if the user enters any number other than 1-5, it goes to the default.Code:int exercises; scanf("%d", &exercises); switch (exercises) { case 1: printf("1"); break; case 2: printf("2"); break; case 3: printf("3"); break; case 4: printf("4"); break; case 5: printf("5"); break; default: printf("Invalid command.\n"); break; } }
But if the user enters a letter, the program will go crazy.
I know that since I'm scanning for only ints, it will only default ints and nothing else.
Any way I can get it to default other kinds of inputs?