C Program to calculate LCF

Simple C Program to calculate least common multiple of two numbers.
#include <stdio.h>
 int main() 
 {
  int a,b,c,multi,hcf,lcm;
 
  printf("Enter first number: ");
  scanf("%d",&a);
  printf("Enter sceond number: ");
  scanf("%d",&b);
  multi=a*b;
  while (b != 0) {
    c = b;
    b = a % b;
    a = c;
  }
 
 hcf=a;
 
 lcm=multi/hcf;
 
  printf("LCM = %d\n",lcm);
 
  return 0;
}




Popular posts from this blog