Question: Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum length of

 Write a program that encrypts and decrypts a string of characters.

Write a program that encrypts and decrypts a string of characters. Use a char array for this, not the string class. The maximum length of a string input to the program will be 200 characters. The input may contain blanks and other whitespace. Your program must request a c-string from the user and encrypt it as described below. If the user enters a single asterisk, the program should stop. Otherwise, encrypt the string, then display the encrypted version. Decrypt it using the inverse of the algorithm below and display the result. This should be the original string. Write a function that performs simple encryption on an array of characters. The encryption algorithm is to add 1 to the first character, 2 to the second, and so on up to 10 to the tenth character. Then add 1 to the 11th character, 2 to the 12th character, and so on. That is, the first, eleventh, 21st and so on characters are incremented by 1, the second, twelfth, 22nd, and so on characters are incremented by 2, etc. Remember how c-strings are stored in memory. Your function should work with any length string. The parameter is the char array and there is no return value; the array you pass will be modified by your function. (This algorithm should look familiar.) To decrypt, subtract 1 from the first character, 2 from the second, and so on, up to subtracting 10 from the 10th character, 1 from the 11", and so on For example, if you entered the string ABC, the output from encryption would be BDF and the result from decryption would be the original string, ABC

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!