Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c
Write a C++ program to Check Vowel or Consonant using switch case

Program to check Vowel or Consonant using switch case in C

Posted on March 10, 2022

Table of Contents

  • Program to check Vowel or Consonant using switch in C
    • Code to find Vowel  or consonant
      • Code to check the Alphabet is Vowel or consonant using switch case  –  #1
      • Code to check the Alphabet is Vowel or consonant using switch case – #2

Program to check Vowel or Consonant using switch in C

In this article, we will discuss the concept of Program to check Vowel or Consonant using switch in C

In this post, we are going to learn how to write a program to  check whether given English alphabet is Vowel or consonant using switch case statement in C language

Code to find Vowel  or consonant

Code to check the Alphabet is Vowel or consonant using switch case  –  #1

In this code, we are going to learn how to write a program to check  the given  English alphabet is Vowel or consonant using switch case statement in C language

Program 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
  char ch;//declare character variable 
     printf("Enter any Alphabets: ");
    scanf("%c",&ch);

    switch(ch){
        //Check lower case vowel
case 'a':
    printf("%c is Vowel",ch);
    break;

case 'e':
    printf("%c is Vowel",ch);
    break;

    case 'i':
    printf("%c is Vowel",ch);
    break;

case 'o':
    printf("%c is Vowel",ch);
    break;

    case 'u':
    printf("%c is Vowel",ch);
    break;

//Check upper case vowel
case 'A':
    printf("%c is Vowel",ch);
    break;

case 'E':
    printf("%c is Vowel",ch);
    break;

     case 'I':
    printf("%c is Vowel",ch);
    break;

    case 'O':
    printf("%c is Vowel",ch);
    break;

    case 'U':
    printf("%c is Vowel",ch);
    break;

    default:
        printf("%c is consonant",ch);
    break;
    }
    getch();
    return 0;
}

When the code is executed, it produces the following result

Case 1

Enter any Alphabets: A
A is Vowel

Case 2

Enter any Alphabets: i
i is Vowel

Case 3

Enter any Alphabets: M
M is consonant

 

Code to check the Alphabet is Vowel or consonant using switch case – #2

In this code, we are going to learn how to write a program to check  the given  English alphabet is Vowel or consonant using switch case statement in C language

Program 2

#include <stdio.h>
#include <stdlib.h>

int main()
{
  char ch;
     printf("Enter any Alphabets: ");
    scanf("%c",&ch);

    switch(ch){
        //Check lower case vowel
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':

//Check upper case vowel
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
    printf("%c is Vowel",ch);
    break;

    default:
        printf("%c is consonant",ch);
    break;
    }
    getch();
    return 0;
}

When the code is executed, it produces the following result

Case 1

Enter any Alphabets: E
E is Vowel

Case 2

Enter any Alphabets: u
u is Vowel

Case3

Enter any Alphabets: K
K is consonant

 

 

Suggested post

if else in C language

Nested if in C language

Operator in C language

Switch case in C language

 

Similar post

Java program to print all alphabets in given range

C program to print all alphabets in given range

C++ program to print all alphabets in given range

 

Java program to print all alphabets using loops

C program to print all alphabets using loops

C++ program to print all alphabets using loops

 

Java program to check whether a character is Alphabet or Not

C++ program to check whether a character is Alphabet or Not

C program to check whether a character is Alphabet or Not

Python program to check whether a character is Alphabet or Not

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes