Question: Please explain how to do this: In part_b.cpp, you should define a function with the following signature: string centered_line(char c, int width, char p, int

Please explain how to do this: In part_b.cpp, you should define a function with the following signature: string centered_line(char c, int width, char p, int padding) When called, this function should return a string. The string sholud consist of sequence of characters (p) followed by a sequence of characters (c) followed by a sequence of characters (p) The values width and padding specify the width of each c and p sequence. When your code is compiled and run, the resulting program should: Declare variables int width, char c, int padding, and char c, using the {}-style initialization Use a while loop to continue until the user ends the program by invoking the end-of-input character (Control+d on Linux and Mac), each time prompting the user to enter four values a char c an int width a char p an int padding. Within the while loop, Print a message confirming the values read Call the centered_line function with the values provided by the user, printing the result What the results should look like A successful run of the program should look like this: $ ./part_b Enter a character and a width for printing, and a character and a width to use for padding before and after: > # 10 _ 5 Printing 10 copies of char '#' with 5 padding using char '_' _____##########_____ > b 7 a 2 Printing 7 copies of char 'b' with 2 padding using char 'a' aabbbbbbbaa >

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!