-
Display with commas
I am writting a function displaywithcommas that accpepts any numer of perameters and is maxed out at a 10 digit numer. This is part of a caclulater program i am writting, and this is what the function should do.
If you enter 1234567890 it should show 123,456,890.
Help me please!
-
www.homeworkhelp.about.com
learn it, use it, save up to 33%!!!!
-
If you plan to output the variable all at once it can't be a numeric variable since it has commas in it. Therefore accept input as a char array. reverse the array with strrev() or write your own reversal funcution. Use a loop to advance down the array one element at a time. Use a counter to keep track of how many steps have been taken. After every third step move all data remaining in array after current index one spot to the right starting with the null operator and working back to desired location. Once desired location is open put a comma in it, jump over the comma and start counting out another three steps. When all commas have been entered reverse the string again and display the result.