A character is vowel or not

It is a program to find a character given by user is vowel or not. The character read from user verified by condition statement. If the condition is satisfied, the character is vowel, otherwise it is not a vowel character.

The two C program shown below finds a character is vowel or not by two different technique. They are,
  • IF conditional statement
  • switch case statement


A character is vowel or not - C program using If condition

The C program finds a given character is vowel or not using a If conditional statement. while the program is running, a character is read from user and verify the given character is satisfied by condition or not.

 

#include <stdio.h>
#include <string.h>

int main() {

  char ch;
  
  printf("\n Find a given character is vowel or not ");
  printf("\n Enter a character :");
  scanf("%c",&ch) ; 

  if ( ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || 
           ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U' )
    {
       printf ( "\n The character %c is  vowel",ch);
   } else {
       printf ( "\n The character %c is not  vowel",ch);
   }
       
   
  return 0;
  
}

 

Output


 Find a given character is vowel or not
 Enter a character : s
 The character s is not  vowel

 Find a given character is vowel or not
 Enter a character : u
 The character u is  vowel
 


A character is Vowel or not - C program switch case

The C program finds a given character is vowel or not using a switch case conditional statement. while the program is running, a character is read from user and verify the given character is satisfied by any of switch case or default.
 

#include <stdio.h>
#include <string.h>

int main() {

  char ch;
  
  printf("\n Find a given character is vowel or not");
  printf("\n Enter a character :");
  scanf("%c",&ch) ; 

  switch(ch) {
  
     case 'a' :
     case 'A' :   
     case 'e' :
     case 'E' :  
     case 'i' :
     case 'I' :  
     case 'o' :
     case 'O' :  
     case 'u' :
     case 'U' :
   printf ( "\n The character %c is  vowel",ch);
          break;   
     default :    
       printf ( "\n The character %c is not vowel",ch);
   
   }          
  return 0;
  
}

 

A character is Vowel or not - C program switch case Output


 Find a given character is vowel or not
 Enter a character : i
 The character i is  vowel

 Find a given character is vowel or not
 Enter a character : k
 The character k is not vowel



Download c program source code


Comments

Popular posts from this blog

Hexadecimal to Binary Conversion

Binary to Decimal conversion -Bitwise Left shift Operator

Convert Octal to Binary