Write C program to enter any character and check whether character is alphabet or not using Conditional/Ternary operator
C , OPERATOR , PROGRAM.
Required knowledge:
Basic C programming, Conditional operator.
Program:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
/** *
C program to check alphabets using Conditional operator */ #include
<stdio.h> int
main() { char
ch; /* *
Reads a character from user */ printf("Enter
any character: "); scanf("%c",
&ch); printf("It
is %s", (((ch>='a' && ch<='z') || (ch>='A'
&&
ch<='Z')) ? "ALPHABET" : "NOT APLHABET") ); return
0; }
|
Output
Enter any character: a
It is ALPHABET
It is ALPHABET
Comments
Post a Comment