Computer Science, asked by Roshan3057, 1 year ago

Write a program to find the lcm and gcd of two numbers in c++

Answers

Answered by sancharimouri
2

Answer:

using namespace std;  

// Recursive function to return gcd of a and b  

int gcd(int a, int b)  

{  

   if (b == 0)  

       return a;  

   return gcd(b, a % b);  

     

}  

   

// Driver program to test above function  

int main()  

{  

   int a = 98, b = 56;  

   cout<<"GCD of "<<a<<" and "<<b<<" is "<<gcd(a, b);  

   return 0;  

}

Similar questions