Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Describe a social audit.

Answered: 1 week ago