// // Program: multiply // // Purpose: test recursive function to multiply two numbers. // // Input: // non-negative integers N, M from standard input. // Output: // the product N*M to standard output, computed without using // the computer's multiplication 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 // ?? multiply(?? n, ?? m); // (Replace "??" with appropriate types.) // Main program. int main(void) { int num1, num2; cout << "Enter two non-negative integers:\n"; cin >> num1 >> num2; if ((num1 < 0) || (num2 < 0)) { cout << "Numbers must not be negative\n"; return EXIT_FAILURE; } cout << num1 << " * " << num2 << " = " << multiply(num1, num2) << endl; return EXIT_SUCCESS; }