LCM:
Stand for Lowest common multiple
Example-
LCM of 5 and 6 is 30
LCM of 4 and 6 is 12
LCM of 10 and 30 is 30
program:
#include < iostream>
using namespace std;
class r4r{
int a,b,lcm;
public:
int get_value()
{
cout<<"Enter first number"<< endl;
cin>>a;
cout<<"Enter second number"<< endl;
cin>>b;
}
int find_lcm()
{
int max,i;
if(a>b)
max=a;
else
max=b;
for(i=max;i<=a*b;i++)
{
if(i%a==0 && i%b==0)
{
cout<<"LCM is "<< i;
break;
}
}
}
};
int main()
{
r4r obj;
obj.get_value();
obj.find_lcm();
return 0;
}
Enter first number
3
Enter second number
4
LCM is 12