/******************************************
This Program gets two positive integers
from the user and computes their GCD.
******************************************/
#include <iostream>
using namespace std;
int main()
{
int a, b;
// Read in a
cout << "Enter a positive integer: ";
cin >> a;
while(a <= 0)
{
cout << "I said *positive*, try again: ";
cin >> a;
}
// Read in b
cout << "Enter a positive integer: ";
cin >> b;
while(b <= 0)
{
cout << "I said *positive*, try again: ";
cin >> b;
}
// Compute gcd
while(b != 0)
{
int r = a % b;
a = b;
b = r;
}
// Write out gcd
cout << "The gcd is " << a << endl;
return 0;
}