LCM and HCF of two numbers


/* C++ program to calculate LCM and HCM of two numbers */
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c;
cout<<"Enter two nos : ";
cin>>a>>b;
c=a*b;
while(a!=b)
{
if(a>b)
a=a-b;
else
b=b-a;
}
cout<< "\n\nHCF \t= " << a;
cout<< "\nLCM \t= " << c/a;
getch();
}


Output:

 
birwa.org


Post a Comment