VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-to-check-vowel-or-consonant/

⇱ C Program to Check Vowel or Consonant - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program to Check Vowel or Consonant

Last Updated : 23 Jul, 2025

In English, there are 5 vowel letters and 21 consonant letters. In lowercase alphabets, 'a', 'e', 'i', 'o', and 'u' are vowels and all other characters ('b', 'c', 'd, 'f'....) are consonants. Similarly in uppercase alphabets, 'A', 'E', 'I', 'O', and 'U' are vowels, and the rest of the characters are consonants.

In this article, we will learn how to write a C program to check if a character is a vowel or consonant.

👁 Vowel and Consonant

Algorithm

The algorithm to check vowels and consonants is simple to understand and implement. Here,

  • Check if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U'), the character is a vowel.
  • Else, the character is a consonant.

C Program to Check Vowel or Consonant

Below is the C program to find if a character is a vowel or consonant using an if-else statement.


Output
The character A is a vowel.

Complexity Analysis

  • Time Complexity: O(1)
  • Auxiliary Space: O(1)

Check Vowel or Consonant using strchr() Function

In the below C program, the str array contains a list of vowels. The strchr() function is used to search for the entered character in the vowels array. If the character is found, the isVowel function returns 1, otherwise, it returns 0.


Output
a is vowel

Complexity Analysis

  • Time Complexity: O(1)
  • Auxiliary Space: O(1)

Refer to the complete article Program to find if a character is vowel or Consonant for more methods to check if a character is a vowel or consonant.

Comment
Article Tags: