OK..guys this one has really stumped me!! I tried going through the logic and using a switch function, but I have been getting some crazy outputs. Plus I have to incorporate a "toupper" function inside it. Is that correct place?
**NOTE: I can not use strings or anything else, b/c we have not learned them yet.**
Thanks for any help!Code:#include <stdio.h> #include <ctype.h> main() { char ch; int i = 0; printf("Enter a phone number: "); while ( ch = getchar() != '\n' ); ch = toupper(ch); switch ( ch ) { case 'A': case 'B': case 'C': i = 2; break; case 'D': case 'E': case 'F': i = 3; break; case 'G': case 'H': case 'I': i = 4; break; case 'J': case 'K': case 'L': i = 5; break; case 'M': case 'N': case 'O': i = 6; break; case 'P': case 'R': case 'S': i = 7; break; case 'T': case 'U': case 'V': i = 8; break; case 'W': case 'X': case 'Y': i = 9; break; default: printf("%d", i); break; } printf("%d", i ); }