/* digits6.cpp is a driver program to test function DigitsIn.
 *
 *  Input:  an integer value
 *  Output: the number of digits in that value
 **************************************************************/

#include <iostream.h>              // cout, cin, <<, >>

int DigitsIn(int intValue);

int main()
{
  int theValue;

  cout << "Enter an integer value: ";
  cin >> theValue;

  cout << theValue << " contains " 
       << DigitsIn(theValue) << " digit(s).\n";

  return 0;
}

/*** Put definition of function DigitsIn() from Figure 6.5 here. ***/

/* DigitsIn counts the digits in an integer value.
 *
 * Receive:  intValue, an integer value
 * Return:   numDigits, the number of digits in intValue
 ***********************************************************/

int DigitsIn(int intValue)
{
   int numDigits = 0;

   do
   {
      numDigits++;
      intValue /= 10;
   }
   while (intValue != 0);

   return numDigits;
}


