I have some problems with a simple program. The purpose of the program is to determine whether a user entered character is a number or a letter. Whats wrong with this code? The first part before the && seems to work but the second part, after the &&. I would really appreciate some help.
int main()
{
char input = '0';
printf("Enter a letter or a number: ");
scanf("%c", &input);
if((input >= '0') && (input <= '9'))
{
printf("The input is a number.\n");
}
else if((input >= 'A' && input <= 'Z') || (input >= 'a' && input <= 'z'))
{
printf("The input is a letter.\n");
}
else
{
printf("The input is not a number or a letter.\n");
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire