An alternative to building a string is to split the integer numerically and print the parts separated by commas to standard output.

The standard way to strip off individual digits from a number is...