Ask your own question, for FREE!
Mathematics 8 Online
OpenStudy (marcelie):

someone help me with c++ programming can someone help me c++ programming http://prnt.sc/d0orui this is what i did #include using namespace std; int main () { cout << "Enter an uppercase letter: "; char uppercasecaseLetter; cin >> uppercasecaseLetter; char lowercaseLetter = static_cast('T' + (lowercaseLetter - 't')); cout << "The lowercase letter is " << lowercaseLetter << endl; return 0; }

zepdrix (zepdrix):

What went wrong? :U Won't compile?

zepdrix (zepdrix):

And what's up with your variable names? LOL upper case case letter...?

OpenStudy (marcelie):

no :/ it compiles but it doesn give me the eaxct solution ... this is what i compile when it gave me the answer http://prnt.sc/d0osr9

OpenStudy (marcelie):

not sure lmao.. i suck at programming

zepdrix (zepdrix):

Isn't there like a nice handy tolower function in c++ I can't remember... What is it that you're trying to do? You're taking the ASCII value of T and subtracting ... hmm doing something..

OpenStudy (johnweldon1993):

^tolower is indeed a function

OpenStudy (marcelie):

oh hmm so then what should be done

zepdrix (zepdrix):

char uppercaseLetter; cin >> char uppercaseLetter; putchar ( tolower(uppercaseLetter) ); Need something like this probably. Crapppp I gotta install C++ tools for Visual Studio >.< Thought they would already be installed lol. Bahh I can't test it just yet :p

OpenStudy (marcelie):

lol

zepdrix (zepdrix):

What uhh... thingy.. IDE do you use for your programming? :D

OpenStudy (518nad):

just use one of them online compilers

zepdrix (zepdrix):

Ohhh :O

OpenStudy (johnweldon1993):

http://cpp.sh/

OpenStudy (marcelie):

visual studio 2010

zepdrix (zepdrix):

noiceee :U

OpenStudy (marcelie):

i entered my code and it gave me this #include <iostream> using namespace std; int main () { cout << "Enter an uppercase letter: "; char uppercasecaseLetter; cin >> uppercasecaseLetter; char lowercaseLetter = static_cast<char>('S' + (lowercaseLetter - 's')); cout << "The lowercase letter is t " << lowercaseLetter << endl; return 0; }

zepdrix (zepdrix):

Notice that at the start... you ask the user for an uppercase letter. And then you don't use that value in any of the rest of your code... weird.

OpenStudy (marcelie):

yeah lool

OpenStudy (marcelie):

it runs in site but it does not compile in my comp

zepdrix (zepdrix):

Oh I guess you don't need that putchar nonsense. I thought the tolower would give us an int or something. Ya this seems to be working for me: #include <iostream> using namespace std; int main () { cout << "Enter an uppercase letter: "; char uppercaseLetter; cin >> uppercaseLetter; char lowercaseLetter = tolower( uppercaseLetter ); cout << "The lowercase letter is " << lowercaseLetter << endl; return 0; }

OpenStudy (johnweldon1993):

#include <iostream> using namespace std; int main () { cout << "Enter an uppercase letter: "; char uppercaseLetter; cin >> uppercaseLetter; char lowercaseLetter; lowercaseLetter = tolower(uppercaseLetter); cout << "The lowercase letter is " << lowercaseLetter << endl; return 0; }

OpenStudy (johnweldon1993):

Oh...haha beat me to it Zap :P

zepdrix (zepdrix):

Oooo snap :x stealin yer thunder!

OpenStudy (marcelie):

yay it workedd ^_^

OpenStudy (marcelie):

can you help me with few more lool

zepdrix (zepdrix):

Ya we can try :U

OpenStudy (marcelie):

okay one sec

OpenStudy (marcelie):

OpenStudy (johnweldon1993):

So first, what have you attempted? Hint* VERY easy if you use the code from the first example we did :)

OpenStudy (marcelie):

hmm okay i i did 4.9 not sure it is is right #include <iostream> using namespace std; int main () { cout << "Enter a character: "; char uppercasecaseLetter; cin >> uppercasecaseLetter; char lowercaseLetter = static_cast<char>('E' + (lowercaseLetter - 'e')); cout << "The ASCII code for the character is 69 " << lowercaseLetter << endl; return 0; }

OpenStudy (johnweldon1993):

Hang on...you can't explicitly say the output will be 69 What if I enter Y as a character? That ASCII code is not 69 :)

zepdrix (zepdrix):

XD

OpenStudy (marcelie):

lool

OpenStudy (johnweldon1993):

Hint* take this guy *What we did for the first problem* and use it to work 4.9 #include <iostream> using namespace std; int main () { cout << "Enter an uppercase letter: "; char uppercaseLetter; cin >> uppercaseLetter; char lowercaseLetter; lowercaseLetter = tolower(uppercaseLetter); cout << "The lowercase letter is " << lowercaseLetter << endl; return 0; } Now...remember we are entering a Character....and we want out a NUMBER *Notice how here we are getting out another character So change up the "wording" and change the other things :D

OpenStudy (johnweldon1993):

Any luck? :)

OpenStudy (marcelie):

not really lol trying to figure it hmm

OpenStudy (johnweldon1993):

So here is what I had for 4.9; compare it with what you have so far! #include <iostream> using namespace std; int main () { cout << "Enter a Character: "; char uppercaseLetter; cin >> uppercaseLetter; int lowercaseLetter; lowercaseLetter = tolower(uppercaseLetter)-32; cout << "The ASCII code for the character is " << lowercaseLetter << endl; return 0; }

OpenStudy (marcelie):

wait so where did the 32 come from ? lol

OpenStudy (johnweldon1993):

Now obviously I could have named "uppercaseLetter" and "lowercaseLetter" something different to match up to what we are doing...but just for quick comparison!

OpenStudy (johnweldon1993):

So in ASCII you have to subtract 32 from the integer *From what I read*

OpenStudy (marcelie):

ohhh

OpenStudy (johnweldon1993):

Was that stated anywhere in your text? In those sections 4.3 - 4.7? O.o

OpenStudy (marcelie):

hmm i think so lol saw one example it had - some numbers oh my teacher skips some some problems so he assigned us 4.8 and few more

zepdrix (zepdrix):

Subtraction, oh that's interesting! :D I was trying to do the thing you were doing earlier marci, with the casting. This is more in reference to 4.8 though: cout << "Enter an ASCII value: "; int value; cin >> value; char letter = static_cast<char>(value); cout << letter << endl; return 0;

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!