C program to find HCF and LCM of two numbers.

#include<conio.h>
void main()
{
 clrscr();
 int a, b, x, y, t, hcf, lcm;
 printf("Enter two number : ");
 scanf("%d%d",&x, &y);
 a=x;
 b=y;
 while(b!=0)
 {
  t=b;
  b=a%b;
  a=t;
 }
 hcf=a;
 lcm=(x*y)/hcf;
 printf("HCF = %d\n",hcf);
 printf("LCM = %d",lcm);
 getch();
}
C program to find HCF and LCM of two numbers. C program to find HCF and LCM of two numbers. Reviewed by on December 22, 2019 Rating: 5

No comments:

Powered by Blogger.