Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. 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 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. 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 11th, 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions