Program to check vowel or not

0 Suresh Chand June 2, 2021

In this program, We will learn program to check vowel or not. To check any character is vowel or not, We will use switch case. Before that, To understand this example, You must have knowledge in following topics

Download Application: Learn C Programming with Live Compiler

Algorithm

This is the algorithm of program to check vowel or not

Step 1: Start

Step 2: Initialize character variable as ch

Step 3: Take input from user and store in ch variable

Step 4:  IF ch is a,e,i,o,u THEN

            Step 4.1: Vowel

Step 5: Else

            Step 5.1: Not Vowel

Step 6: End

Flowchart

This is the flowchart to check whether character is vowel or not

Flowchart : Program to check vowel or not

Now, Let’s look at code to understand how to whether character is vowel or not with the use of switch

CODE: Use of Else if

#include<stdio.h>

int main()
{
    
    char ch;
    printf("Input 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%c is a vowel.", ch);
            break;
        default:
            printf("\n%c is not a vowel.", ch);
    }
    
    return 0;
} 

Download Application: Learn C Programming with Live Compiler

The output of above program is

Input a Character :  a
a is a vowel.

Input a Character :  d
d is not a vowel.

We will use switch case to check vowel or not. In the same place, We can also use if else condition to check the vowel or not.

if( ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U' ){
    //print character is vowel
}else{
    // print character is not vowel
}

You can use any of the above condition.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Join Our Newsletter Now

Get the latest tutorials, examples and projects updates.

Ads Block Detector Powered by codehelppro.com

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Disable Ad Block

Want Same System