C

C Program to Check Whether an Alphabet is Vowel or Consonant Using Function

In this tutorial, we are going to see how to write a C program to check whether an alphabet is a vowel or consonant using function. There are six alphabets (A, E, I, O, U, and Y) are called vowels. All the remaining alphabets except these five are called consonants. There are three ways to check whether an alphabet is a vowel or consonant, by using if-else, switch-case, or by function.
 

C Program to Check Whether an Alphabet is Vowel or Consonant Using Function
#include <stdio.h>

int isVowel(char c)
{
    if (c >= 'A' && c <= 'Z')
       c = c + 32; 
 
    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y')
       return 1;
 
    return 0;
}

int main()
{
    char c;
    printf("Enter a character: \n");
    scanf(" %c", &c);
    
    if(isVowel(c))  {
    printf("\n %c is a vowel.", c);
  }
    else {
      printf("\n %c is a consonant.", c);
  }
    return 0;
}

Output:

Enter a character: a

 a is a vowel.

 

mcqMCQPractice competitive and technical Multiple Choice Questions and Answers (MCQs) with simple and logical explanations to prepare for tests and interviews.Read More

Leave a Reply

Your email address will not be published. Required fields are marked *