• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
August 02, 2022 |640 Views
C Program to Check Whether an Alphabet is Vowel or Consonant
  Share  2 Likes
Description
Discussion

In this video, we will see a C Program to Check Whether an Alphabet is Vowel or Consonant. 

The alphabet is made up of 26 letters, 5 of which are vowels (a, e, i, o, u) and the rest of which are consonants. 

Let's have a close look at the algorithm:

Algorithm: 
Step 1: Take a variable 'ch' and define as a character type. 
Step 2: Take a input from user. 
Step 3: Check a condition for both lower and upper case vowels. 

IF (ch == 'a' || ch == 'A' || 
ch == 'e' || ch == 'E' || 
ch == 'i' || ch == 'I' || 
ch == 'o' || ch == 'O' || 
ch == 'u' || ch == 'U' ) 

Step 4: Print "Vowel" if the condition is true. 
Step 5: Print "Consonant" if the condition is false. 

Time & Space Complexity:
Here time and space complexity for this method are O(1) & O(1). 

Example
Input : x = 'B' 
Output : Consonant 

Input : x = 'A' 
Output : Vowel 

C Program to Check Whether an Alphabet is Vowel or Consonant : https://www.geeksforgeeks.org/c-program-to-check-vowel-or-consonant/