In: Computer Science
Write a subroutine that will receive a char input value. This subroutine should then use a switch statement to determine if the char is a vowel, consonant, digit, or other type of character.
Write the subroutine only,
Here I have preffered C for creating subroutine, As no language
preference was given
It will receive a char input value
after than it will use switch statement
void main()
{
char s;
scanf("%c",&s);
switch(s)
{
case '0':
printf("Digit");
break;
case '1':
printf("Digit");
break;
case '2':
printf("Digit");
break;
case '3':
printf("Digit");
break;
case '4':
printf("Digit");
break;
case '5':
printf("Digit");
break;
case '6':
printf("Digit");
break;
case '7':
printf("Digit");
break;
case '8':
printf("Digit");
break;
case '9':
printf("Digit");
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;
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 'b':
printf("Consonant");
break;
case 'c':
printf("Consonant");
break;
case 'd':
printf("Consonant");
break;
case 'f':
printf("Consonant");
break;
case 'g':
printf("Consonant");
break;
case 'h':
printf("Consonant");
break;
case 'j':
printf("Consonant");
break;
case 'k':
printf("Consonant");
break;
case 'l':
printf("Consonant");
break;
case 'm':
printf("Consonant");
break;
case 'n':
printf("Consonant");
break;
case 'p':
printf("Consonant");
break;
case 'q':
printf("Consonant");
break;
case 'r':
printf("Consonant");
break;
case 's':
printf("Consonant");
break;
case 't':
printf("Consonant");
break;
case 'v':
printf("Consonant");
break;
case 'w':
printf("Consonant");
break;
case 'x':
printf("Consonant");
break;
case 'y':
printf("Consonant");
break;
case 'z':
printf("Consonant");
break;
case 'B':
printf("Consonant");
break;
case 'C':
printf("Consonant");
break;
case 'D':
printf("Consonant");
break;
case 'F':
printf("Consonant");
break;
case 'G':
printf("Consonant");
break;
case 'H':
printf("Consonant");
break;
case 'J':
printf("Consonant");
break;
case 'K':
printf("Consonant");
break;
case 'L':
printf("Consonant");
break;
case 'M':
printf("Consonant");
break;
case 'N':
printf("Consonant");
break;
case 'P':
printf("Consonant");
break;
case 'Q':
printf("Consonant");
break;
case 'R':
printf("Consonant");
break;
case 'S':
printf("Consonant");
break;
case 'T':
printf("Consonant");
break;
case 'V':
printf("Consonant");
break;
case 'W':
printf("Consonant");
break;
case 'X':
printf("Consonant");
break;
case 'Y':
printf("Consonant");
break;
case 'Z':
printf("Consonant");
break;
default:
printf("Other type of character");
}
}
Hope it helps !! If any problem Do comment