#include<iostream>
using namespace std;
int main()
{ int num1,num2;
int m1,m2,r;
cout<<"enter two numbers"<<endl;
cin>>num1>>num2;
if(num1>num2)
{
m1=num1;
m2=num2;
}
else
{ m1=num2;
m2=num1;
}
while(r!=0)
{
r=m1%m2;
m1=m2;
m2=r;
}
cout<<"result of gcd of two number is "<<m1<<endl;
int lcm= (num1*num2)/m1;
cout<<"result of lcm of two number is "<<lcm;
}
using namespace std;
int main()
{ int num1,num2;
int m1,m2,r;
cout<<"enter two numbers"<<endl;
cin>>num1>>num2;
if(num1>num2)
{
m1=num1;
m2=num2;
}
else
{ m1=num2;
m2=num1;
}
while(r!=0)
{
r=m1%m2;
m1=m2;
m2=r;
}
cout<<"result of gcd of two number is "<<m1<<endl;
int lcm= (num1*num2)/m1;
cout<<"result of lcm of two number is "<<lcm;
}
No comments:
Post a Comment