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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started