Logic:
- Enter character ch
- A character is vowel only if it is any one of the characters a, e, i, o, u, A, E, I, O, U
- Otherwise It is a consonant
Algorithm
- Enter charcater ch
- switch (ch)
- {
- case ‘a’ :
- case ‘A’ :
- case ‘e’ :
- case ‘E’ :
- case ‘i’ :
- case ‘I’ :
- case ‘o’ :
- case ‘O’ :
- case ‘u’ :
- case ‘U’ : printf(“It is a vowel”);
- break ;
- default : printf(“It is a consonant”);
- }
Program
#include <stdio.h> int main() { printf("***************************************************************"); printf("\n***************************************************************"); printf("\n**WAP to enter a character & tell its type vowel or consonant**"); printf("\n** Created by Sheetal Garg **"); printf("\n** Assistant Professor **"); printf("\n** Phone No:9467863365 **"); printf("\n***************************************************************"); printf("\n***************************************************************\n"); char ch; printf("enter a character\n"); 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(" It is a vowel"); break ; default : printf("It is a consonant"); } return 0; }
Output 1:
************************************************************************ ************************************************************************ ** WAP to enter a character & tell its type vowel or consonant in C ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ************************************************************************ ************************************************************************ enter a character A It is a vowel
Output 2:
************************************************************************ ************************************************************************ ** WAP to enter a character & tell its type vowel or consonant in C ** ** Created by Sheetal Garg ** ** Assistant Professor ** ** Phone No:9467863365 ** ************************************************************************ ************************************************************************ enter a character B It is a consonant