4

C Program to Check Whether an Alphabet is Vowel or Consonant

 2 years ago
source link: https://www.geeksforgeeks.org/videos/c-program-to-check-whether-an-alphabet-is-vowel-or-consonant/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

C Program to Check Whether an Alphabet is Vowel or Consonant

C Program to Check Whether an Alphabet is Vowel or Consonant
Hello everyone. Welcome to the geek for geeks. My name
  • 50 Views
  • 02/08/2022

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 

Program to find whether a character is vowel or consonant:
https://www.geeksforgeeks.org/program-find-character-vowel-consonant/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK