Vowel and Consonants in C
#include<stdio.h>
void main()
{
char alphbt;
printf("Enter an alphabet:\n");
scanf("%c", &alphbt);
switch(alphbt)
{
case 'a':printf("It is a vowel.");
break;
case 'e':printf("It is a vowel.");
break;
case 'i':printf("It is a vowel.");
break;
case 'o':printf("It is a vowel.");
break;
case 'u':printf("It is a vowel.");
break;
default:printf("It is a consonant.");
}
}
OUTPUT
LOGIC
Step 1: We are taking an alphabet from the user.
Step 2: We are using switch case statement to check whether the entered alphabet is vowel or consonant.
Condition specified in case is checked and if it is false then default statement is displayed.
0 Comments