CMSC 201

Lab 11: Strings

Ceasar's Cipher

Ceasar's cipher is an incredibly simple encryption algorithm: given a sentance, the encryption translates each letter further into the alphabet some distance k. So for Ceasar's cyper with k = 2, every a in the original sentance will become a c, every b will become a d, etc. The cypher wraps around the alphabet, so a z would become a b. To decode it you just reverse the translation.

For this lab you will take a string from the user, follwed by a k. You will then print out the string translated k characters.

Sample output:

Please enter a string: A banana
Please enter k: 4

Your string is: E ferere