I'd declare a function accepting an int and returning void.
The stopping value would be when the int passed in is less than 10, since that would be
Eigen digit
If the int passed in wasn't the Eigen digit, then I'd declare an int called temp to pass to the next call of the funciton and I'd determine the individual digits of the int passed in by sequentially passing the int passed in through a loop, decreasing the value of the int passed in by dividing by 10 each time through the loop and continuing as long as the modified value of the int passed in was greater than zero. Within the loop I'd get the right hand digit of the current value of the int passed in by using modulo operator (% 10) and adding it to temp, before dividing the current value by 10. When the loop finished I'd recursively call the function, passing it temp.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Offline 2,253 posts
since Jul 2005