CODE ONLINE PLEASE VISIT ANY OF THE FOLLOWING....

HCF and LCM USING C


//TESTED IN TERMINAL
//C program to find hcf and lcm: The code below finds highest common factor and least common multiple of two integers. HCF is also known as greatest common divisor(GCD) or greatest common factor(gcf).

#include<stdio.h>
void main()
{
 int a,b,c,d,e;
  printf("Enter 2 numbers:\n");
  scanf("%d %d",&a,&b);
  c=a;d=b;
   while(a!=b)
    {
    if(a>b)
      a=a-b;
    else
      b=b-a;
    }
printf("hcf of %d and %d is %d\n",c,d,a);

{
  e=((c*d)/a);
printf("lcm of %d and %d is %d\n",c,d,e);
}
}






















































































Comments

Popular posts from this blog

INTRODUCTION TO PYTHON

Fibonacci series by using c

TO FIND ODD NUMBERS UP TO N