Computer Science, asked by tanupriyatommy, 7 months ago

Write a C program to check whether a character is an alphabet or not and if it is an alphabet then check whether it is a vowel or a consonant using if-else and switch.


Example: If A is given, program should print A is an alphabet and a vowel.

If 9 is given, program should print 9 is not an alphabet.

If h is given, program should print h is an alphabet and a consonant.


At the time of execution, the program should print the message on the console as:

Enter a character :

For example, if the user gives the input as S:

Enter a character : S

then the program should print the result as:

S is an alphabet and a consonant

Note: Do use the printf() function with a newline character (\n).

Answers

Answered by prasad1611
1

Answer:

Explanation:

if((ch >= 97 && ch <= 122) || (ch >= 65 && ch <= 90)) printf("The entered character %c is an Alphabet",ch); else printf("The entered character %c is not an Alphabet",ch); The ASCII value of 'a' is 97, 'z' is 122, 'A' is 65 and 'Z' is 9

The character entered by the user is stored in variable c.

The lowercase variable evaluates to 1 (true) if c is a lowercase vowel and 0 (false) for any other characters.

Similarly, the uppercase variable evaluates to 1 (true) if c is an uppercase vowel and 0 (false) for any other character.

If either lowercase or uppercase variable is 1 (true), the entered character is a vowel.

However, if both lowercase and uppercase variables are 0, the entered character is a consonant.

Similar questions