Check Vowel or Consonant Character C Programming

By | June 22, 2019

“Check Vowel or Consonant Character” is a C program to input a character and check whether it is vowel or consonant.
This C program uses nested if else statement for condition checking.

C Program Vowel or Consonant Checker program

C Program Vowel or Consonant Checker program

/*
Write a C program to check whether
a character is vowel or consonant alphabet
*/
#include<stdio.h>  
int main()   
{   
  
   char ch;
    /* Input character at run time from user */
    printf("Enter a character to check for Vowel or Consonant: ");
    scanf("%c", &ch);

    /* check if character is alphabet a to z or A to Z */
	if( (ch>='a' && ch<='z') || (ch>='A' && ch<='Z') )
     {
	   /* check if character is vowel AIOU or aiou */
	   if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || 
           ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
    
	       printf("'%c' is Vowel.", ch);
        else
           printf("%c is a Consonant");
     }
     else 
       printf("'%c' is not an Alphabet.", ch);
    
    return 0;
}

 2,969 total views,  1 views today

Leave a Reply

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