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-21T12:02:23-0400
#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':
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment