Question

In: Computer Science

Write a subroutine that will receive a char input value. This subroutine should then use a...

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,

Solutions

Expert Solution

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


Related Solutions

c++ Write the definition of a function named ‘isLower’ that takes as input a char value...
c++ Write the definition of a function named ‘isLower’ that takes as input a char value and returns true if the character is lowercase; otherwise, it returns false.•Print the message “The character xis lowercase” when returned value above is true, and vice versa.
Write a subroutine that takes an int (.long) parameter and squares it. The parameter should be...
Write a subroutine that takes an int (.long) parameter and squares it. The parameter should be passed in on the stack. The answer should be returned in eax. The subroutine should not disturb any registers except eax, ecx, and edx. (Save any registers on the stack and restore them before exiting the subroutine.) Upon entry to the subroutine, push ebp, etc., to access the parameter.
write a java program to Translate or Encrypt the given string : (input char is all...
write a java program to Translate or Encrypt the given string : (input char is all in capital letters) { 15 } *) Each character replaced by new character based on its position value in english alphabet. As A is position is 1, and Z is position 26. *) New characters will be formed after skipping the N (position value MOD 10) char forward. A->A+1= B , B->B+2=D ,C->C+3=F, .... Y->Y+(25%10)->Y+5=D A B C D E F G H I...
Write a function that will receive two input arguments that is the height in inches (in.)...
Write a function that will receive two input arguments that is the height in inches (in.) and the weight in pounds (lb) of a person and return two output arguments that is the height in meters (m) and mass in kilograms (kg). Determine in SI units the height and mass of a 5 ft.15 in. person who weight 180 lb. Determine your own height and weight in SI units. Note: 1 meter = 39.3701 inch, 1 foot = 12 inches,...
Use python write a function that translates the input string into Pig Latin. The translation should...
Use python write a function that translates the input string into Pig Latin. The translation should be done word by word, where all words will be separated by only one space. You may assume that each word must have at least one vowel (a,e,i,o,u and uppercased counterparts), and there will be no punctuation or other special characters in the input string. The Pig Latin rules are as follows: For words that begin with consonants, all letters before the initial vowel...
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds...
Write in C programming language Write the function replace(char b[], char f[], char t[]). which finds the string 'f' in the string 'b' and replaces it with the string 't'. You can assume that f and t same length Example: char string[] = "zap";     replace(string, "ap", "oo"); --changes 'string' to "zoo".     *don't assume substring being replaced is singular, or that its own substrings are unique.     *Don't re scan letters already checked and replaced         char string[] =...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes...
[ Write in C, not C++] Define a function char* deleteSymbol(char *s, char x) that removes the character x from string s. For s[] = “America”, a call to deleteSymbol(s, ‘a’) converts s[] = “Ame”
Write a program that encrypts and decrypts the user input. Note – Your input should be...
Write a program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x) given by...
Use MATLAB to write a function subroutine horner_yourlastname(a, x0, d) that uses Horner’s algorithm to evaluate...
Use MATLAB to write a function subroutine horner_yourlastname(a, x0, d) that uses Horner’s algorithm to evaluate a polynomial at a given point x0. This code should have three inputs in the order specified above: a: a vector of coefficients of the polynomial of interest. The first element of the vector should be the leading coefficient, and the last element should be the trailing coefficient. i. e. The polynomial p(x) = anx n + an−1x n−1 . . . a1x +...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password...
-Write in C++ -Use Char library functions Write a function that accepts a string representing password and determines whether the string is a valid password. A valid password as the following properties: 1. At least 8 characters long 2. Has at least one upper case letter 3. Has at least one lower case letter 4. Has at least one digit 5. Has at least on special character
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT