C Program to check whether a given(lowecase or uppercase)character is vowel or consonant[ switch statement ]
// switch statement to check vowel or consonant
#include <stdio.h>
void main()
{
char c;
printf("Enter any alphabet:\n ");
scanf("%c", &c);
switch(c)
{
case 'a':
printf("Vowel");
break;
case 'e':
printf("Vowel");
break;
case 'i':
printf("Vowel");
break;
case 'o':
printf("Vowel");
break;
case 'u':
printf("Vowel");
break;
case 'A':
printf("Vowel");
break;
case 'E':
printf("Vowel");
break;
case 'I':
printf("Vowel");
break;
case 'O':
printf("Vowel");
break;
case 'U':
printf("Vowel");
break;
default:
printf("Consonant");
}
}
note : //break statement terminate the program if case is true otherwise nothing.
ALTERNATIVE :
#include <stdio.h>
main()
{
char c;
printf("Enter any character: ");
scanf("%c", &c);
switch(c)
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
printf("Vowel");
break;
default:
printf("Consonant");
}
}
output;
"Enter any alphabet:a
vowel.
ALSO SEE:
[if else statement for same program ]
https://cprogramming00.blogspot.com/2020/01/program-to-check-whether-givenlowecase.html
0 comments:
Post a Comment