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

Write a C++ program to Check Vowel or Consonant using switch case

Posted on March 10, 2022

Table of Contents

  • Write a C++ program to Check Vowel or Consonant using switch case
    • Code to check given Alphabet is Vowel or consonant
      • Code to check given Alphabet is Vowel or consonant, using switch – #1
      • Code to check given Alphabet is Vowel or consonant, using switch   – #2

Write a C++ program to Check Vowel or Consonant using switch case

In this article, we will discuss the concept of Write a C++ program to Check Vowel or Consonant using switch case

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 statements in C++ language

Code to check given Alphabet is Vowel or consonant

Code to check given Alphabet is Vowel or consonant, using switch – #1

In this code, we are going to learn how to check  the given  English alphabet is Vowel or consonant using Switch case statements in C++ language

Program 1

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
  char ch;//declare a character variable
    cout<<"Enter any Alphabets: ";
//Ask input from the user
    cin>>ch;
//Reading the input from the user
    switch(ch){
case 'a':
    cout<<ch<<" is Vowel";
    break;

    case 'e':
   cout<<ch<< "is Vowel";
    break;

     case 'i':
   cout<<ch<< "is Vowel";
    break;

     case 'o':
   cout<<ch<< "is Vowel";
    break;

     case 'u':
   cout<<ch<< "is Vowel";
    break;//check lower case alphabets

case 'A':
    cout<<ch<< "is Vowel";
    break;

    case 'E':
   cout<<ch<< "is Vowel";
    break;

     case 'I':
   cout<<ch<< "is Vowel";
    break;

     case 'O':
   cout<<ch<< "is Vowel";
    break;

     case 'U':
   cout<<ch<< "is Vowel";
    break;//check upper case alphabets

    default:
        cout<<ch<< "is Consonant";
    break;
    }
    getch();
    return 0;
}


When the above code is executed, it produces the following result

Case 1

Enter any character: g
g is a constan

Case 2

Enter any character: U
U is a Vowel

 

Code to check given Alphabet is Vowel or consonant, using switch   – #2

In this code, we are going to learn how to check  the given  English alphabet is Vowel or consonant using Switch case statements in C++ language

Program 2

#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
  char ch;
    cout<<"Enter any Alphabets: ";
    cin>>ch;

    switch(ch){
case 'a':
case 'e':
     case 'i':
     case 'o':
     case 'u':
    //check lower case Vowel

case 'A':
    case 'E':
     case 'I':
     case 'O':
     case 'U':
//check Upper case Vowel
 cout<<ch<< "is Vowel";
    break;

    default:
        cout<<ch<< "is Consonant";
    break;
    }
    getch();
    return 0;
}


When the above code is executed, it produces the following result

Case 1

Enter any character: M
M is a constant

Case 2

Enter any character: U
U is a Vowel

 

Suggested post

If else statement in C++

Nested if statement in C++

Operator in C++ language

Switch statements 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