#include<stdio.h>
main()
{
int n1,n2,num1,num2,lcm,rem;
printf("\nEnter two numbers=");
scanf("%d%d",&num1,&num2);
printf("\nThe two numbers are %d and %d",num1,num2);
if(num1>num2)
{
n1=num1;
n2=num2;
}
else
{
n1=num2;
n2=num1;
}
while(n2%n1!=0)
{
rem=n2%n1;
n2=n1;
n1=rem;
}
lcm=(num1*num2)/n1;
printf("\nH.C.F. of %d and %d is %d",num1,num2,n1);
printf("\nL.C.M. of %d and %d is %d",num1,num2,lcm);
}
main()
{
int n1,n2,num1,num2,lcm,rem;
printf("\nEnter two numbers=");
scanf("%d%d",&num1,&num2);
printf("\nThe two numbers are %d and %d",num1,num2);
if(num1>num2)
{
n1=num1;
n2=num2;
}
else
{
n1=num2;
n2=num1;
}
while(n2%n1!=0)
{
rem=n2%n1;
n2=n1;
n1=rem;
}
lcm=(num1*num2)/n1;
printf("\nH.C.F. of %d and %d is %d",num1,num2,n1);
printf("\nL.C.M. of %d and %d is %d",num1,num2,lcm);
}
No comments:
Post a Comment