// // Program: gcd // // Purpose: test function for finding the greatest commong // divisor of two positive integers. // // Input: // positive integers N, M from standard input. // Output: // the greatest common divisor of N and M printed to standard // output. // #include #include // Pre: n > 0, m > 0. // Post: returns the greatest common divisor of n and m. // ADD YOUR FUNCTION HERE. // The prototype should be of the form // ?? gcd(?? n, ?? m); // (Replace "??" with appropriate types.) // Main program. int main(void) { int num1, num2; cout << "Enter two positive integers:\n"; cin >> num1 >> num2; if ((num1 <= 0) || (num2 <= 0)) { cout << "Numbers must be positive\n"; return EXIT_FAILURE; } cout << "The greatest common divisor of " << num1 << " and " << num2 << " is " << gcd(num1, num2) << endl; return EXIT_SUCCESS; }