Write a function to format numbers as two digits. /** * Formats a number as 2 digits, with a leading 0 if needed * *

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Write a function to format numbers as two digits. /** * Formats a number as 2 digits, with a leading 0 if needed * *

Post by answerhappygod »

Write a function to format numbers as two digits.
/** * Formats a number as 2 digits, with a leading 0 ifneeded * * @param n number to format, assumed between 0 and 59,inclusive * @return two digit string representation of number */string twoDigitString(unsigned int n) { /** * You may wish to change this function when you bringit into your program. * For now please get it to work here with the existingfunction signature. * You may assume <string> has beenincluded. */ // TODO: your code here to implement the method // return the two digit string}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply