Problem Description
Enter a data to determine whether the data is a letter
operation result
method one
Method Two
Code
method one
#include <stdio.h>
#include <ctype.h>
int main() {
char ch;
printf("请输入一个字符:");
scanf("%c", &ch);
if (isalpha(ch)) {
printf("输入的字符是字母。\n");
} else {
printf("输入的字符不是字母。\n");
}
return 0;
}
Method 2: (not perfect)
#include<stdio.h>
int main(){
char word;
scanf("%c",&word);
if(word>='a' && word<='z' || word>='A'&& word<='Z'){
printf("YES\n");
}else{
printf("No\n");
}
return 0;
}