current position:Home>C language: input a character from the keyboard to judge whether it is an English letter.

C language: input a character from the keyboard to judge whether it is an English letter.

2022-02-02 20:20:54 CSDN Q & A

Enter a character from the keyboard , Determine whether it is an English letter .

This is my answer

#include<stdio.h>int main(){    char c;    scanf("%c",&c);    if('A'<c<'Z'||'a'<c<'z')    printf(" yes ");    else printf(" no ");    return 0; }

But no matter what character I type , The running results are “ yes ”. What went wrong ?

My solution ideas and tried methods
What I want to achieve



Refer to the answer 1:
#include<stdio.h>int main(){    char c;    scanf("%c",&c);    if(('A'<=c&&c<='Z')||('a'<=c&&c<='z'))    printf(" yes ");    else printf(" no ");    return 0; }



Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202022020522879.html

Random recommended