Answer to Question #17764 in C++ for apoorva
Write a C++ function to find at least common divisor of two integers.
1
2012-11-05T09:58:34-0500
#include <iostream>
using namespace std;
main()
{int a,b,i=2,k=-1;
cout<<"Enter a: ";
cin>>a;
cout<<"Enter b: ";
cin>>b;
while(k==-1 && i<(a+b)){
if(a%i==0 && b%i==0)
& k=i;
i++;
}
if(k!=-1)
cout<<"Least common divisor:& "<<k<<"\n";
else cout<<"No common divisor\n";
system("pause");
& }
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment