For some reason i cant get my GCD function to return anything in my main function someone help?
#include<iostream>
using namespace std;
int firstanswer;
int secondanswer;
int a;
int b;
int gcd (int a,int b)
{
int t;
while ( b != 0);
{
t = b;
b = a % b;
a = t;
}
return a;
}
int main()
{
cout << "Please enter your first integer: ";
cin >> firstanswer;
cout << "Now please enter your second integer: ";
cin >> secondanswer;
cout << "The GCD of " << endl;
cout << firstanswer << endl;
cout << "and" << endl;
cout << secondanswer << endl;
cout << "is" << endl;
cout << gcd(firstanswer, secondanswer) << endl;
return 0;
}
HERE IS MY OUTPUT:
Please enter your first integer: 10
Now please enter your second integer: 5
The GCD of
10
and
5
is
^CPress any key to continue . . .