How would I make all letters be an invalid input? I want all letters, numbers greater than 20, and numbers less than or equal to 0 to be invalid inputs. I used an or cause I want any case to be an invalid input. Any help would be greatly appreciated.
#include <stdio.h>
#include <math.h>
int main (void)
{
float purchase = 0;
printf("Please enter amount of purchase:\n");
printf("purchase: ");
scanf("%f" , &purchase);
printf("The purchase you entered is: $%.2f\n", purchase);
if((purchase > 20) || (purchase <= 0))
{
printf("Invalid purchase amount\n");
printf("Amount should be greater than 0 and less than or");
printf(" equal to 20\n");
return 1;
}
return 0;
}