C Program To Find LCM and HCF Of Two Number -1

How to write a C Program To Find LCM and HCF Of Two Number -1 in C Programming Language ?


Solution For C Program :

/*C Program To Find LCM and HCF Of Two Number -1.*/

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,old_rem,cur_rem,new_rem,lcm,hcf;
clrscr();
printf("Enter the two no:");
scanf("%d%d",&a,&b);
if(a<b)
  {
  old_rem=b;
  cur_rem=a;
  }
  else
  {
  old_rem=a;
  cur_rem=b;
  }
do{
  new_rem=old_rem%cur_rem;
  old_rem=cur_rem;
  cur_rem=new_rem;
  }while(new_rem!=0);
hcf=old_rem;
lcm=(a*b)/hcf;
printf("LCM=%d\tHCF=%d",lcm,hcf);
getch();
}


You may also learn these C Program/Code :

C Program To Swap Two Numbers Without Using Third Variable


Learn More :