Question: there something wrong in my index A Caesar (or rotation) cipher is a simple system of encoding strings by shifting every letter forward (or backward)


there something wrong in my index
A Caesar (or rotation) cipher is a simple system of encoding strings by shifting every letter forward (or backward) by a given amount. For example, if the shift amount is 3, then the letter A becomes D. B becomes E, C becomes F, and so on. Letters near the end of the alphabet wrap around; for a shift of 3, X becomes A. Y becomes B. Z becomes 0. Write a program that inputs an entire line from the keyboard, followed by an integer shift amount. The program encodes the line and outputs the result. Here are two examples: Secret message? Attack zerg at dawn Shift amount? 3 Result: DWWDEN CHUJ DW GDZO Secret message? DWWDFN CHUJ DW GDZQ Shift amount? -3 Result: ATTACK ZERG AT DAWN Assume the input consists of letters and spaces only; the letters can be lowercase ('a-z) or uppercase (A-2). The resulting message should consist of uppercase letters only. You may assume the shift amount is in the range -26. 26. Hints: First, you can use the at() function, or array notation [ ], to access characters in the string, or to change a character: 3.at (1) = 'X'; // 3[i] = 'X' also works Second, it's very helpful to think of characters as numbers when performing these types of manipulations. Third, you might find the islower() and toupperfunctions helpful, these are discussed in the next section. Why? Since the result is uppercase, it might be easier to convert to uppercase before performing a shift, that way you only have one case to deal with when shifting.] 1 #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
