Question
Implement the following (Called a Ceasar Cypher, since it was used in Ceasar's time) using this function prototype in the same file. char* cypher(string str,
Implement the following (Called a Ceasar Cypher, since it was used in Ceasar's time) using this function prototype in the same file. char* cypher(string str, int rotate); The idea is that you will declare a variable of type string and give it a value in main. Then pass it into the cypher function. Cypher will create a cstring by copying the str to a new char* of size str.size(). Remember that you can covert with str.c_str( ). Then you will rotate ever letter by an amount passed into the function. If you look at the ascii table You will see that A is 65 and z is 122. We want to keep every character between these ascii codes. So, you will probably need an if statement noting: If after adding the rotate value and taking the modulus of one after z (123), the value is between 65 and 123, then set the character to that value. Otherwise, because you did a mod of 123, you know the number is no larger than 122 (then goes back to zero).so in that case you would want to add 65 to take it to A. Don't forget to return the char*. Then print out the cstring with puts. e.g. char* cstr = new char[size]; puts(cstr); For output, set the string to "ABC" and call cypher("ABC", 0); #include for test purpose result
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started