// // Program: divide // // Purpose: test recursive function to divide two numbers. // // Input: // non-negative integer N and positive integer M from standard // input. // Output: // the quotient N/M to standard output, computed without using // the computer's division operation. // #include #include // Pre: n >= 0, m > 0. // Post: returns n*m, computed without using the C++ "/" operator. // ADD YOUR FUNCTION HERE. // The prototype should be of the form // ?? divide(?? n, ?? m); // (Replace "??" with appropriate types.) // Main program. int main(void) { int num1, num2; cout << "Enter a non-negative integer and a positive integer:\n"; cin >> num1 >> num2; if ((num1 < 0) || (num2 <= 0)) { cout << "First number must be non-negative, second positive\n"; return EXIT_FAILURE; } cout << num1 << " / " << num2 << " = " << divide(num1, num2) << endl; return EXIT_SUCCESS; }