#include <stdio.h>

void printWithCommas (unsigned int);
void printHelper (unsigned int);

void printWithCommas (unsigned int n) {
    if (n < 1000) {
	printf ("%u", n);
    } else {
	printHelper (n);
    }
    printf ("\n");
}

void printHelper (unsigned int n) {
    unsigned int last3;
    if (n < 1000) {
	printf ("%u", n);
    } else {
	last3 = n % 1000;
	printHelper (n / 1000);
	printf (",%03d", last3);
    }
}

int main ( ) {
/*
    printWithCommas (0);
    printWithCommas (999);
    printWithCommas (1000);
    printWithCommas (12345);
    printWithCommas (123456);
*/
    printWithCommas (1234567);
/*
    printWithCommas (12345678);
    printWithCommas (123456789);
    printWithCommas (123456000);
    printWithCommas (123000789);
    printWithCommas (100000000);
*/
    return 0;
}
