Write a C program to check whether an alphabet is a vowel or consonant. Pictorial Presentation: Sample Solution: C Code: Sample Output: Flowchart: C Programming Code Editor:C Conditional Statement: Exercise-17 with Solution
Improve this sample solution and post your code through Disqus.
Previous: Write a C program to check whether a character is an alphabet, digit or special character.
Next:
Write a C program to calculate profit and loss on a transaction.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
C Programming: Tips of the Day
How to convert an enum type variable to a string?
There really is no beautiful way of doing this. Just set up an array of strings indexed by the enum.
If you do a lot of output, you can define an operator << that takes an enum parameter and does the lookup for you.
Ref: //bit.ly/2Xm2lMX
- Exercises: Weekly Top 16 Most Popular Topics
- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- JavaScript basic - Exercises, Practice, Solution
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- JavaScript conditional statements and loops - Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools
- JavaScript: HTML Form Validation
WAP in c to check vowel and cosonent using switch
A user inputs a character, and we check whether it’s a vowel or not using switch case statement. The alphabets ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ (both lowercase and uppercase) are known as vowels. Alphabets except vowels are known as consonants.
Let's take an example :
Output :
Please enter any single character:a
its vowel
Output
:
Please enter any single character:b
its consonant
Using Switch Case
By using switch case we also check that the inputs character is vowel or not.
Let's take an example :
#include<stdio.h> int main() { char c; printf("Please enter any single character:"); scanf("%s",&c); switch(c) { case 'a': printf("a is vowel"); break; case 'e': printf("e is vowel"); break; case 'i': printf("i is vowel"); break; case 'o': printf("o is vowel"); break; case 'u': printf("u is vowel"); break; default: printf("its consonant"); } return 0; }Output :
Please enter any single character:i
i is vowel
Output :
Please enter any single character:b
its consonant