Also view this program using if else -
C program to check whether a character is alphabet or not using if else.
Required knowledge:
Basic C programming, Conditional operator.Program:
/** * 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
Happy coding ;)
You may also like
- C program to check whether an alphabet is vowel or consonant.
- C program to check whether a character is alphabet, digit or any special character.
- C program to print all alphabets from a to z.
- C program to print ASCII values of all characters.
- C program to check even or odd using conditional operator.
- C program to check leap year using conditional operator.
- C program to find maximum between two numbers using conditional operator.
- C program to find maximum between three numbers using conditional operator.
- C program to check whether a number is even or odd number using conditional operator.
- C program to check leap year using conditional operator.
- C program to enter week number and print day of week name.
- C program to convert length from centimeter to meter and kilometer.
- C program to convert temperature from Celsius to Fahrenheit.
- C program to find square root of any number.
- C program to print different star(*) pattern series.