Question: C++ 2. Write a program which asks user for a string and then alters the string by doing the following to the string. A *

C++

2. Write a program which asks user for a string and then alters the string by doing the following to the string.

A * is inserted BEFORE the 5th character of the string

A $ is inserted AFTER the 10th character of the string

A @ is inserted AFTER the 6th to the last character of the string

Assume the input source into the function is a string which is of length greater than or equal to 16.

Original String

Altered string

abcdefghijklmnop

abcd*efghij$k@lmnop

abcdefghijklmnopq

abcd*efghij$kl@mnopq

abcdefghijklmnopqr

abcd*efghij$klm@nopqr

Please write two different solutions:

One solution using any of the string modifying functions.

One solution using only the push_back , at functions and length functions.

Each solution will ask the user for the original string and then print out the altered string.

Test with the three inputs in the table above Original String- Altered String

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!