#include<stdio.h>
#include<conio.h>
void main(){
int a,b,hcf,lcm,rem,divisor,factor;
printf("Enter Two Integer Numbers.\n");
scanf("%d%d",&a,&b);
if (a!=0&&b!=0) {
if (a>b){
divisor=b;
factor=a;
rem=a%b;
}
else {
divisor=a;
factor=b;
rem=b%a;
}
while (rem!=0){
factor=divisor;
divider=rem;
rem=factor%divisor;
}
hcf=divisor;
}
else {
if (a==0)
hcf=b;
else
hcf=a;
}
lcm=(a*b)/hcf;
printf("HCF of %d and %d = %d\n",a,b,hcf);
printf("LCM of %d and %d = %d\n",a,b,lcm);
getch();
}
No comments:
Post a Comment