Question: Write a function named addCommas that accepts a string representing a number and returns a new string with a comma at every third position, starting

 Write a function named addCommas that accepts a string representing a

Write a function named addCommas that accepts a string representing a number and returns a new string with a comma at every third position, starting from the right. For example: addCommas ("12345678") -> "12,345,678" Complete the following files: strings.cpp 1 #include"strings.h" 2 string addCommas(string s) 3 { 4 int n = s.length() - 3; 5 while (n > 0) 6 { 7 s.insert(n, ","); 8 = 3; 9 } 10 return s; 11 ] 12 n strings.h 1 #ifndef STRINGS_H 2 #define STRINGS_H 3 #include 4 using namespace std; 5 string addCommas(string s) 6 7 #endif Submit Testers Running Tester.cpp pass fail fail fail header guards written for strings.h Expected: header guards written for strings.h Header file strings.h contains using namespace directive. Expected: Header file strings.h has NO using namespace directive. string library type in strings.h NOT fully qualified. Expected: string library type in strings.h is fully qualified. string argument passed by value in strings.h. Expected: string argument passed by const reference in strings.h. Testing client.cpp Test 1 what number to process: 973359471 973,359,471 pass

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!