#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x, y,m,n, hcf, lcm;
printf("\n Enter two number : ");
scanf("%d%d",&x, &y);
m=x;
n=y;
while(m!=n)
{
if(m>n)
m=m-n;
else
n=n-m;
}
hcf=m;
lcm=(x*y)/hcf;
printf("\n HCF of %d and %d is %d",x,y,hcf);
printf("\n LCM of %d and %d is %d",x,y,lcm);
getch();
}
Run1:
Run2:
Previous Next
#include<conio.h>
void main()
{
clrscr();
int x, y,m,n, hcf, lcm;
printf("\n Enter two number : ");
scanf("%d%d",&x, &y);
m=x;
n=y;
while(m!=n)
{
if(m>n)
m=m-n;
else
n=n-m;
}
hcf=m;
lcm=(x*y)/hcf;
printf("\n HCF of %d and %d is %d",x,y,hcf);
printf("\n LCM of %d and %d is %d",x,y,lcm);
getch();
}
Run1:
Run2:
Previous Next
Thank u sir.
ReplyDeleteI am searching this program in many website.
But no clear.
Now your concept is easy.