Hello, I am fairly new to programming and need some help with the while loop.
Here is the part that I am having trouble with.
Code:
#include <stdio.h>
int main ( ) {
int veh;
printf("\nDo you have a car? (1:Yes, 2:No): ");
scanf("%d", &veh);
while (veh < 1 || veh > 2) {
printf("Please select 1 for Yes or 2 for No: ");
scanf("%d", &veh);
}
return 0;
}
The problem is is that when I type in a letter instead of a number, it displays a wall of "Please select 1 for Yes or 2 for No: ". Is there a way to fix this?
Thanks