Question

Write a C code using switch statement that will ask the user to enter a character. This character should be one of the first
0 0
Add a comment Improve this question Transcribed image text
Answer #1

This program is not possible because as per rules

  • The expression (after switch keyword) must yield an integer value i.e the expression should be an integer or a variable or an expression that evaluates to an integer.

For example

switch(a)

switch(a + b + c)

switch(ch1 + a)

switch(a < b)

switch(my_func(12))

switch('a')

  • We can not use such expressions which evaluate floating point values or strings or characters.

Eg. switch(a + 12.2) // expression must yield an integer value not double or float.

switch(f1==name[0])   

switch("string")

Also for case below types of constants are not allowed

case "string"  // string constants are not allowed

case 1.2       // floating point constants are not allowed

case a         // variables are not allowed

case a + b     // variables are not allowed

case 1,2,3     // each case must contain only one constant

Add a comment
Know the answer?
Add Answer to:
Write a C code using switch statement that will ask the user to enter a character....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 14.3: More Sentences Write a program that allows a user to enter a sentence and then...

    14.3: More Sentences Write a program that allows a user to enter a sentence and then the position of two characters in the sentence. The program should then report whether the two characters are identical or different. When the two characters are identical, the program should display the message: <char> and <char> are identical! Note that <char> should be replaced with the characters from the String. See example output below for more information. When the two characters are different, the...

  • Python Ask the user to enter a character and find out if the character is numeric...

    Python Ask the user to enter a character and find out if the character is numeric (a digit from 0-9), an uppercase letter, a lowercase letter, or none of these. Remember that all characters are defined by ASCII codes, and you do not need to convert the input to int or float. You can just compare it with other values. For example, if the entered character is between 'a an d 'z, the character is a lowercase letter.

  • write using C language Part A: Using any loop statement Ask the user to enter first...

    write using C language Part A: Using any loop statement Ask the user to enter first name and last name Read the characters the user typed using getchar) function. While reading you have to make sure you ignore the end of line statement. Print the characters on the screen using putchar () function and in this format First Name:Jack Last Name:Damon

  • ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of...

    ****C PROGRAMMING**** (100 points) Write a program that prompts the user to enter the name of a file. The program encoded sentences in the file and writes the encoded sentences to the output file. Enter the file name: messages.txt Output: encoded words are written to file: messages.txt.swt The program reads the content of the file and encodes a sentence by switching every alphabetical letter (lower case or upper case) with alphabetical position i, with the letter with alphabetical position 25...

  • In a file called First SecondNext.java, write a program that: • Asks the user to enter...

    In a file called First SecondNext.java, write a program that: • Asks the user to enter a string that contains at least five letters. It is OK if your program crashes when the user enters a string with length less than 5. • Stores that string in a variable called s. • Creates a variable called "first", and sets it equal to the first letter of s. • Creates a variable called "second", and sets it equal to the second...

  • ASAP using c++ vectors Create a vector of characters and ask the user to enter their...

    ASAP using c++ vectors Create a vector of characters and ask the user to enter their name, store each letter in the vector, then output the vector 1 letter per line.

  • Python code Write a program that will ask the user to input two strings, assign the...

    Python code Write a program that will ask the user to input two strings, assign the strings to variables m and n If the first or second string is less than 10 characters, the program must output a warning message that the string is too short The program must join the strings m and n with the join function The output must be displayed. Please name the program and provide at least one code comment (10)

  • Write a Python program, with comments, to do the following:                        Ask the user to enter...

    Write a Python program, with comments, to do the following:                        Ask the user to enter a string with at least 7 characters. Assume user will enter a valid string. Assign the string to a variable str1 and print str1. In a loop do the following: Update the value of str1 so that the first character from the current value of str1 is removed and added to the end. Print the updated str1.       The loop should continue until updated...

  • Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To...

    Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...

  • USING PYTHON PROGRAMING LANGUAGE Write a program that first asks the user to enter a “special”...

    USING PYTHON PROGRAMING LANGUAGE Write a program that first asks the user to enter a “special” letter. The program should then ask the user to enter a single line sentence containing all lowercase letters and no punctuation, except for a period at the end. The program will then output the number of times that this letter appears in the sentence. Example: Enter a special letter: t Enter a sentence: here is my little sentence. Your letter appears 3 times. (t...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT