By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 779 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Shift a string by receiving a string converting it to ascii and then shifting it and

P: 1
SMy instructor gave me a psuedocode but I'm still stuck.
get a char
while not end of input:
change char so it's 0-25
shift it forward the appropriate value
"normalize" it so it's still 0-25
change char back to a letter by adding 'a' to it
print it
get next char
end while

Basically if you were to input hello should get out uryyb because it shifted over 13 places. If someone could explain how I should approach this I would be forever greatful.
Jul 2 '16 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,197
Look at the ASCII table.

There an A is 65. To make the A a B you just add 1 to make it 66.

All char variables will display the symbol rather than the integer value.

in your case you just add 13 to H and you are done.

Please note this works only for values in the ASCII table in the range 32-126. That is, the displayable characters.
Jul 2 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.