Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Language Examples - Checking for a Letter

C Language Examples - Checking for a Letter

C Language Examples C Language Examples

The user enters a character, and the program determines whether it is a letter.

Example

#include

<

stdio.h

int

main

(

)

{

char

c

;

printf

(

"

Enter a character:

"

)

;

scanf

(

"

%c

"

,&

c

)

;

if

(

(

c

='

a

' &&

c

<='

z

'

)

||

(

c

='

A

' &&

c

<='

Z

'

)

)

printf

(

"

%c is a letter

"

,

c

)

;

else

printf

(

"

%c is not a letter

"

,

c

)

;

return

0

;

}

Running result:



输入一个字符: a

a 是字母

C Language Examples C Language Examples