Hi all!

Can anybody see where I'm going wrong here? I think it may be something to do with the while loop in the division function but I can't work it out! Any help much appreciated...

Code:// separatingDigits.cpp // Write program segments that accomplish each of the following: // a) Calculate the integer part of the quotient when integer a is divided by integer b. // b) Calculate the integer remainder when integer a is divided by integer b. // c) Use the program pieces developed in (a) and (b) to write a function that inputs an // integer between 1 and 32767 and prints it as a series of digits, each pair of which is // separated by two spaces. For example, the integer 4562 should print as follows: // 4 5 6 2 #include <iostream> using namespace std; void divisionPart ( int ); void moduloPart ( int ); int main() { int userNumber = 0; // to store user input while ( userNumber < 1 || userNumber > 32767 ) // verification to ensure user input is between 1 & 32767 { cout << "Enter number: "; // ask user for input cin >> userNumber; // save user input } // end while divisionPart ( userNumber ); // use functions to get the numbers moduloPart ( userNumber ); // to get the final number } // end main // function to calculate the integer part void divisionPart ( int a ) { while ( a > 0 ) { static int i = 10; // to keep its value each time called int result; // necessary so that the constant variable can be increased upon each iteration result = a / i; // find the next number i *= 10; // increase variable i for the next iteration cout << " " << result; // return the result } // end if } // end function divisionPart // function to calculate the remainder part void moduloPart ( int a ) { cout << " " << a % 10; } // end function moduloPart