Sunday 26 January 2014

find Hcf and Lcm

#include<stdio.h>
int main()
{
int a,b,x,y,t,gcd,lcm;
printf("Enter two numbers\n");
scanf("%d%d",&x,&y);
a=x;
b=x;
while(b!=0)
{
t=b;
b=a%b;
a=t;
}
gcd=a;
lcm=(x*y)/gcd;
printf("Greatest common divisot of %d and %d=%d \n",x,y,lcm);
return 0;
}

No comments:

Post a Comment