Hi,
im lost and i need help writing a function gcd that returns the greatest common divisor of two integers and has to allow five sets of numbers to be input by the user.
this is what i have so far where i put /* is where i need help the most. if someone could also explain it to me that will also be very well appreciated. thank you in advance
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
/* prototype for gcd */
int main()
{
int a;
int b;
for(intj=1; j<=5; j++)
{
cout<<"Enter two integers: ";
cin>>a>>b;
cout<<" The greatest common divisor of "<< a<<" and"<<b<<" is"
<< /* function call for gcd */<<"\n\n";
}
return 0;
}
/*header for gcd */
{
int greatest=1;
for(int i = 2; i <= ( (x < y) ? x : y); ++i)
if( /* condition to see if both x and y are divisible by i */ )
greater =1;
/* statement to return greatest common divisor of both numbers */
}
<< moderator edit: added [code][/code] tags >>