Dec 6, 2010 at 4:29am UTC
Have a choice to input 3 letters S or P or Q. I need to convert them to upper if user inputs lower cased letters.
Dec 6, 2010 at 8:20pm UTC
1 2 3 4 5 6 7 8 9
//First input
cout << setw(63) << "S for squareroot P for Power Q to Quit: " ;
cin >> LETTER;
cout << "\n" ;
UPPER = toupper( 's' );
//If the input isnt Quit
while (LETTER != 'Q' )
what am i doing wrong? it doesnt work
Last edited on Dec 6, 2010 at 8:56pm UTC
Dec 6, 2010 at 10:12pm UTC
you can make 6 separate char .
char a ='s'
char b ='S'
char c = 'q'
and so on...
then char a == char b, char c == char d,...
this is one possible ways.
or you can do this
try replacing line 9 with while toupper((LETTER != 'q' ))
Last edited on Dec 6, 2010 at 10:12pm UTC
Dec 7, 2010 at 12:29am UTC
store the input
char letter;
cin >> letter;
then subtract 32 from the char to change its ascii code.
letter ascii
a = 97
A = 65
Dec 7, 2010 at 12:52am UTC
@leecheneler:
If you do it that way then you have to make sure the letter isn't already uppercase. Otherwise 'A' would be converted to '!'.
Last edited on Dec 7, 2010 at 1:03am UTC
Dec 7, 2010 at 1:00am UTC
Yes sorry, i forgot to mention the fail safes.