64 765
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #17764 in C++ for apoorva

Question #17764
Write a C++ function to find at least common divisor of two integers.
Expert's answer
#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!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions