write a program to calculate hcf and lcm of two number in c++
Answers
Answered by
2
/* C++ Program - Find HCF and LCM of Two Numbers */
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a, b, x, y, t, hcf, lcm;
cout<<"Enter two number : ";
cin>>x>>y;
a=x;
b=y;
while(b!=0)
{ t=b; b=a%b; a=t; }
hcf=a;
lcm=(x*y)/hcf;
cout<<"HCF = "<<hcf<<"\n"
cout<<"LCM = "<<lcm<<"\n";
getch();
plz follow and make brei....thankyu
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a, b, x, y, t, hcf, lcm;
cout<<"Enter two number : ";
cin>>x>>y;
a=x;
b=y;
while(b!=0)
{ t=b; b=a%b; a=t; }
hcf=a;
lcm=(x*y)/hcf;
cout<<"HCF = "<<hcf<<"\n"
cout<<"LCM = "<<lcm<<"\n";
getch();
plz follow and make brei....thankyu
Similar questions