63 076
Assignments Done
99,1%
Successfully Done
In July 2018

Answer to Question #15122 in C++ for Zac

Question #15122
Write a C++ program that makes use of a switch statement but without the use of
ANY if statements. The program reads in a character (not including a white space)
from the user and then display accordingly:
"The input is a digit", if the character is between ‘0’ and ‘9’
"The input is an upper case letter” if the character is between ‘A’ and ‘Z”
"The input is a lower case letter" if the character is between ‘a’ and ‘z’
"The input is a special symbol” if otherwise
Expert's answer
#include <iostream>




using namespace std;




void main(){

char c;

cout << "Enter character: ";

cin >> c;

switch(c){

case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case
'0':cout <<
"The input is a digit";

break;

case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case
'K': case 'L': case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R': case
'S': case 'T': case 'V': case 'W': case 'X': case 'Y': case 'Z':

cout << "The input is an upper case letter";

break;

case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case
'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case
's': case 't': case 'v': case 'w': case 'x': case 'y': case 'z':

cout << "The input is an lower case letter";

break;

default:

cout << "The input is a special symbol";

break;

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions