anonymous
  • anonymous
please need help with c++.........Write a program that reads from the user a letter, and prints out the digit value corresponding to this letter based on the encoding on a mobile phone's keypad. For example, for a, b, or c, the program would print the digit 1. If the letter entered is not one of the letters of the alphabet, print a value of -1. Use a switch statement
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
jamiebookeater
  • jamiebookeater
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
The more naive approach would be something of the like: if (input_from_user == 'a' || input_from_user == 'b' || if input_from_user == 'c') printf("1\n"); if (input_from_user == 'd' || .... ) printf("2\n"); Now you can do it with the switch statemente, just remember to break out of the case, and you can bundle multiple cases together, i.e.: case 'a' : case 'b' : case 'c' : printf("1\n"); break; //more code P.S.: Consider other input, and consider the input of upper case letters also. Hope this was helpful :-)
anonymous
  • anonymous
thank you that was really helpful

Looking for something else?

Not the answer you are looking for? Search for more explanations.