Program To Find LCM of Two Numbers:
#include<iostream>
using namespace std;
main()
{
int num1,num2,min,hcf,i,lcm;
cout<<"Enter Two Numbers To Find LCM\n";
cin>>num1>>num2;
min=(num1<num2)? num1:num2;
for(i=1;i<=min;i++)
{
if(num1%i==0&&num2%i==0)
{
hcf=i;
}
} lcm=(num1*num2)/hcf;
cout<<"\nLeast Common Multiple Is "<<lcm;
return 0;
}
#include<iostream>
using namespace std;
main()
{
int num1,num2,min,hcf,i,lcm;
cout<<"Enter Two Numbers To Find LCM\n";
cin>>num1>>num2;
min=(num1<num2)? num1:num2;
for(i=1;i<=min;i++)
{
if(num1%i==0&&num2%i==0)
{
hcf=i;
}
} lcm=(num1*num2)/hcf;
cout<<"\nLeast Common Multiple Is "<<lcm;
return 0;
}