// A1Q3.cpp #include #include using namespace std; int GCD (int x, int y); int main() { int x,y; cout << "Enter number of 2 positive integers: "; cin >> x >> y; if ((x>0)&&(y>0)) { cout << "The greatest common divisor of 2 positive integers is "; cout << GCD (x,y) << endl; //call function GCD (x,y); } else cout << "You input (an) invalid integer(s)."; return 0; } int GCD (int x, int y) { int temp,r; if (x< y) { temp=x; x=y; y=temp; } r=x%y; while(r!=0) { x=y; y=r; r=x%y; } return y; }