To check whether the given character is vowel or consonant

 Program:


#include<stdio.h>
#include<conio.h>
void main()
{
    char ch;
    clrscr();
    printf("Enter any Character : ");
    scanf("%c",  &ch);
    if((ch>='a' && ch<='z') || (ch>='A' && ch<='Z'))
    {
        if(ch=='a' || ch=='A' || ch=='e' || ch=='E' || ch=='i' || ch=='I' || ch=='o' || ch=='O' || ch=='u' || ch=='U')
            printf("Given Character is a Vowel");
        else
            printf("Given Character is a consonant");
    }
    else
        printf("Given Character is not an Alphabet");
    getch();
}

Output:

Ex-1:
Enter any Character : a
Given Character is a Vowel

Ex-2:
Enter any Character : E
Given Character is a Vowel

Ex-3:
Enter any Character : i
Given Character is a Vowel

Ex-4:
Enter any Character : O
Given Character is a Vowel

Ex-5:
Enter any Character : b
Given Character is a Consonant

Ex-6:
Enter any Character : 3
Given Character is not an Alphabet


Next Topic        :  

Previous Topic :

No comments:

Post a Comment