Computer C++ program to find the LCM and GCD of two numbers
#include
#include
void main()
{
clrscr();
int x,y,gcd=1;
cout<< "ENTER 1st NO : "; cin>>x;
cout<<"\n\nEnter 2nd NO. :"; cin>>y;
for(int i=1;i<1000;++i)
{
if((x%i==0)&&(y%i==0))
gcd=i;
}
cout<<"\n\n\nGCD :"<
cout<<"\n\n\nLCM :"<<(x*y)/gcd;
getch();
}
OUTPUT:
ENTER 1st NO : 12
ENTER 2nd NO. :13
GCD :1
LCM :156


Post a Comment