EmbLogic's Blog

Program to find the HCF and LCM of two numbers.

//HCF and LCM of two nos.

#include
int main()
{
int a,b,num1,num2,deno,nume,rem=1,lcm;

printf(“\nEnter two nos: “);
scanf(“%d %d”,&a,&b);

if(a>b)
{
num1=a;
num2=b;
}

else
{
num1=b;
num2=a;
}

nume=num1;
deno=num2;

while(rem!=0)
{
rem=nume%deno;
nume=deno;
deno=rem;
}

printf(“\nHCF: %d “,nume);
lcm=(num1*num2)/nume;
printf(“\nLCM: %d “,lcm);

return 0;

}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>