Question: C++ C++ C++ C++ C++ I need help with this. Please provide comments for each section that way I can see what's going on. The

C++ C++ C++ C++ C++

I need help with this. Please provide comments for each section that way I can see what's going on. The more comments the better. Any help is appreciated.

Read in an integer (any valid 64-bit integer = long long type) and output the same number but with commas inserted. So if the user entered -1234567890 your program should output -1,234,567,890. Commas should appear after every three significant digits (provided more digits remain) starting from the decimal point and working left toward more significant digits. If the number entered does not require commas, do not add any. For example, if the input is 234 you should output 234. The input 0 should produce output 0. Note in the example above that the number can be positive or negative. Your output must maintain the case of the input.

This problem could be easily solved if you were allowed to read the information in as a string or character by character. However, the input will be read in as a single integer and you will need to use appropriate arithmetic to isolate and print each digit of the number one at a time and output commas at appropriate locations.

/******************************************************** * Description: * Displays a 64-bit integer (long long) with * commas for thousands, millions, billions, etc. * * ** ABSOLUTELY NO ARRAYS, NO `string`, NO `vector` ** * usage is allowed. * * Instead, you may only declare: * * bool, * int, or * int64_t (long long) * * The only library function allowed is pow(base, exp) * defined in the library. * ********************************************************/

#include #include using namespace std;

int main() { long long n; cout << "Enter an integer:" << endl; /*====================*/ /* Start of your code */

/* End of your code */ /*==================*/ return 0; }

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!