// Ask used for two integers and output GCD // #include using namespace std; //function protopypes int getPosInt(); int computeGCD(int , int); int main() { //declare variables int a , b; //get a and b from user a= getPosInt(); //invoke the function for a b = getPosInt(); //invoke to get b // Compute gcd a = computeGCD(a,b); // Write out gcd cout << "The gcd is " << a << endl; return 0; } //define function int getPosInt() { int temp; do{ cout << "Enter positive integer: "; cin >> temp; }while(temp <= 0); return temp; } int computeGCD(int a1, int b1) { while(b1 != 0) { int r = a1 % b1; a1 = b1; b1 = r; } return a1; }