Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

What is the principle of thermodynamics? Explain with examples

Answered: 1 week ago