When I debug, for instance a t input, it keeps outputting the corresponding number is 8 over an over until I exit it. Need help finding my mistake.
" "
" "
" "
#include <iostream>
using namespace std;
int main()
{
char letter;
cout << "Enter a letter: ";
cin >> letter;
while (letter != '#')
{
cout << "The corresponding number is ";
switch (letter)
{
case 'A':
case 'a':
case 'B':
case 'b':
case 'C':
case 'c':
cout << "2" << endl;
break;
case 'D':
case 'd':
case 'E':
case 'e':
case 'F':
case 'f':
cout << "3" << endl;
break;
case 'G':
case 'g':
case 'H':
case 'h':
case 'I':
case 'i':
cout << "4" << endl;
break;
case 'J':
case 'j':
case 'K':
case 'k':
case 'L':
case 'l':
cout << "5" << endl;
break;
case 'M':
case 'm':
case 'N':
case 'n':
case 'O':
case 'o':
cout << "6" << endl;
break;
case 'P':
case 'p':
case 'Q':
case 'q':
case 'R':
case 'r':
case 'S':
case 's':
cout << "7" << endl;
break;
case 'T':
case 't':
case 'U':
case 'u':
case 'V':
case 'v':
cout << "8" << endl;
break;
case 'W':
case 'w':
case 'X':
case 'x':
case 'Y':
case 'y':
case 'Z':
case 'z':
cout << "9" << endl;
break;
Ok I understand that much now. So it seems like that line I have needs to be altered in some way, but if I get rid of the "!= '#'" it gives no output at all. Is there something else that should be in the # position?
you may put these two inside the loop, so the it will still ask for a letter to input everytime it loops, and then there will be now a possibility that the loop will stop