Write a program to find the lcm and gcd of two numbers in c++
Answers
Answered by
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
Physics,
6 months ago
Computer Science,
1 year ago
Computer Science,
1 year ago
English,
1 year ago
Biology,
1 year ago
History,
1 year ago