Question

In: Computer Science

WRITTEN IN C PLEASE. Write a switch statement that tests the value of the char variable...

WRITTEN IN C PLEASE.

Write a switch statement that tests the value of the char variable response and performs the following actions: if response is y, the message Your request is being processed is printed if response is n, the message Thank you anyway for your consideration is printed if response is h, the message Sorry, no help is currently available is printed for any other value of response, the message Invalid entry; please try again is printed

Solutions

Expert Solution

#include<stdio.h>

int main(){

  char response;

  printf("Enter char: ");

  scanf("%c",&response);

  //starting switch case with given char

  switch(response){

  // two cases for upper and lower cases

    case 'Y':

    case 'y':

      printf("Your request is being processed");

      break;

  // two cases for upper and lower cases    

    case 'n':

    case 'N':

      printf("Thank you anyway for your consideration");

      break;

  // two cases for upper and lower cases

    case 'h':

    case 'H':

      printf("Sorry, no help is currently available");

      break;

    default: printf("Invalid entry");

  }

}

Note : If you like my answer please rate and help me it is very Imp for me


Related Solutions

Question: Write a complete C++ program that runs multiple tests and calculations using switch statement. Based...
Question: Write a complete C++ program that runs multiple tests and calculations using switch statement. Based on your input and the selection from the keyboard, the program does the followings. If the selection is 1, the program should test the input if it’s positive, negative or zero. For example, the output should be “The selection is 1 to test the input value if it’s positive, negative or equal to zero. The input value 7 is positive” If the selection is...
Define a char variable. Read a char value from the keyboard into the variable. Print the...
Define a char variable. Read a char value from the keyboard into the variable. Print the variables value.
Using c# , Write a program using a switch statement that takes one character value from...
Using c# , Write a program using a switch statement that takes one character value from the user and checks whether the entered value is an arithmetic operator (+, -, * , /) If not the program display a message that it not of the operators ( (+, -, * , /) .
[ 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”
A Switch/case statement allows multiway branching based on the value of an integer variable. In the...
A Switch/case statement allows multiway branching based on the value of an integer variable. In the following example, the switch variable s is specified to be assumed to be one of three values ​​of [0, 2], and a different action for each case becomes: case 0: a = a - 1; break; case 1: a = a + 2; break; case 2: b = 3 * b; break; Shows how such statements can be compiled into MiniMIPS assembly instructions.
A switch/case statement allows multiway branching based on the value of an integer variable. In the...
A switch/case statement allows multiway branching based on the value of an integer variable. In the following example, the switch variables can assume one of the three values in [0, 2] and a different action is specified for each case. switch (s) {    case 0: a=a+1; break;    case 1: a=a-1; break;    case 2: b=2*b; break; } Show how such a statement can be compiled into MiniMIPS assembly instructions.
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.
Please make it simply and easy for a beginner to follow.. -Write in C++ -Use Char...
Please make it simply and easy for a beginner to follow.. -Write in C++ -Use Char library functions -Must show that is runs 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...
Please make it simply and easy for a beginner to follow -Write in C++ -Use Char...
Please make it simply and easy for a beginner to follow -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 characte
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[] =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT