Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How do I write this program fragment? I\'ve been trying to use a for loop and a

ID: 3611348 • Letter: H

Question

How do I write this program fragment?

I've been trying to use a for loop and a switch inside it but I'mnot getting anywhere, I don't even know if I'm on the right track,please help.

Here is what we're supposed to write:


Consider this program fragment:

const int MAXLEN= 150;

char line[MAXLEN];

cin.getline(line, MAXLEN);

char target[5*MAXLEN];

Write a loop that works through each of the characters in thearray line, copying them into the chararray target, but with these rules:

·        stopcopying if the target array is full, considering the terminatingnull character.

·        replaceevery * character with the string star,

·        replaceevery + character with the string shape,and

·        replaceevery = character with thestring brighten.

For example, if the user enters this line:

Twinkle little *, = and + my *day

your target array should contain this:

Twinkle little star, brighten and shape my starday

Don't forget to write a terminating null character whenrequired.  Also, use a C-string function, forexample, strcat, where appropriate.

Explanation / Answer

Answer no longer needed

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote