/*
 * Solution to Problem 1 (C++)
 * 13th Annual CS Programming Contest
 * WCU Dept of Math and CS
 * Copyright 2002 , All Rights Reserved
 *
 * Problem Statement:
 * Displaying an Integer with Commas.
 * This program prompts the user for an integer. It then displays
 * the integer (and an explanatory string) with commas between
 * every set of three digits. The solution must be able to handle
 * arbitrarily large integer values. You can not assume that 
 * the integer has at most some specific finite number of digits.
 * For example, if the maximum size of the int data type were
 * to be increased on a new machine, your program should not fail.
 * You must read in and process the integer as an integer, not 
 * as a string.
 *
 * Because the program must handle arbitrarily large integers
 * it uses recursion. At each step in the recursion the program 
 * uses the mod operator to find the value of the least significant
 * three digits (that is, the rightmost three digits) and uses
 * the integer division operator to 
 */

#include <iostream.h>

void displayWithCommas(int number);
void displayThreeDigits(int number);

int main()
{
  long int number;

  cout << "Enter one integer value: ";
  cin >> number;
  cout << "The integer with commas is: ";
  displayWithCommas(number);
  cout << endl;
}

void displayWithCommas(int number)
{
  if (number < 1000)
    cout << number;
  else
  {
    displayWithCommas(number / 1000);
    cout << ",";
    displayThreeDigits(number % 1000);
  }
}

void displayThreeDigits(int number)
{
  cout << number;
}

