Dremendo Tag Line

Input alphabet check vowel or not using switch case in C++

switch case - Question 2

In this question, we will see how to input an alphabet in lowercase and check if it is a vowel or not in C++ programming using the switch case statement. To know more about switch case statement click on the switch case statement lesson.

Q2) Write a program in C++ to input an alphabet in lowercase and check if it is a vowel or not using the switch case statement.

Program

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
    char c;
    cout<<"Enter an alphabet in lowercase ";
    cin>>c;
    switch(c)
    {
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            cout<<"Vowel";
            break;

        default:
            cout<<"Not a vowel";
    }
    return 0;
}

Output

Enter an alphabet in lowercase i
Vowel
video-poster