One of the requirements of this project is that if the user enters a letter into the calculator, I have to display a message that you can't do that and let them try again. This is my attempt.
int main(void) {
char r = 't';
double a;
while (r == 't') {
printf("enter the number\n");
if (scanf(" %lf", &a)) {
r='f';
} else
printf("Invalid entry, try again\n");
}
printf("a is %lf", a);
}
It works properly for some letters, like n. But for many others, like r, it goes into an infinite loop
Invalid entry, try again enter the number"