Write a function with the following header to format a posi- tive integer with the specified width: string format(int number, int width) The function returns a string for the number with one or more...


Write a function with the following header to format a posi- tive integer with the specified width:


string format(int number, int width)
The function returns a string for the number with one or more prefix 0s. The size of the string is the width. For example, format(34, 4) returns 0034 and format(34, 5) returns 00034. If the number is longer than the width, the function returns the string representation for the number. For example, format(34, 1) returns 34.
Write a test program that prompts the user to enter a number and its width and displays a string returned by invoking format(number, width).



Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here