The error I get is Line 8: error: 'euclidean_algorithm' was not declared in this scope
Does anyone know what's wrong?
Code:
int main(int argc, char *argv[]) {
int x,y,aa;
cout << "enter number 1: " << endl;
cin >> x;
cout << "enter number 2: " << endl;
cin >> y;
aa=euclidean_algorithm(x,y);
}
int euclidean_algorithm(int a, int b) {
// the first thing to do is to make sure a > b. If it is not, swap them.
if (b > a) { int t = a; a = b; b = t; }
// now we run the algorithm in a loop
while (b != 0) {
int temp = a % b;
a = b;
b = temp;
}
cout << "the greatest common denominator is " << a << endl;
}