Answer to Question #15195 in C++ for Zack Magi

Question #15195
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
1
Expert's answer
2012-09-21T10:13:15-0400
#include <iostream>
using namespace std;
int main (void)
{
int number;
cout << "Please input something: ";
cin >> number;

switch (number)
{
case 0:
cout << "The input is a digit" << endl;
break;
case 1:
cout << "The input is a digt" << endl;
break;
case 2:
cout << "The input is a digt" << endl;
break;
case 3:
cout << "The input is a digt" << endl;
break;
case 4:
cout << "The input is a digt" << endl;
break;
case 5:
cout << "The input is a digt" << endl;
break;
case 6:
cout << "The input is a digt" << endl;
break;
case 7:
cout << "The input is a digt" << endl;
break;
case 8:
cout << "The input is a digt" << endl;
break;
case 9:
cout << "The input is a digt" << endl;
break;


default:
cout << "The input is wrong" << endl;
break;
}

system ("pause");
return (0);
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS