#include<iostream>
usingnamespace std;
int main()
{
char letter;
int digit;
cout <<"Please enter a single letter in upper case,and I will tell you what the corresponding digit is on the telephone:";
cin >> letter;
switch (digit)
{
case'A':
case'B':
case'C':
digit= 2;
}
#include<iostream>
#include <cctype>
usingnamespace std;
int main()
{
char letter;
int digit;
cout <<"Please enter a single letter, and I will tell you what the corresponding digit is on the telephone:";
cin >> letter;
letter = toupper( letter );
switch ( letter )
{
case'A': case'B': case'C':
digit= 2;
cout << digit << " corresponds to " << letter << endl;
break;
default:
cout << letter << " is unknown\n";
break;
}
return ( 0 );
}
toupper is a standard C function that converts a letter to upper case. This will allow a user to input either a low case letter or upper case letter. That is your program will be more smart and will convert a letter to upper case itself.