#include<stdio.h>
#include<conio.h>
int lcm(int n1,int n2);
void main()
{
int n1,n2,x,y;
clrscr();
printf("\nEnter two numbers:");
scanf("%d %d",&n1,&n2);
printf("L.C.M is=%d",lcm(n1,n2));
getch();
}
// Function Definition
int lcm(int n1,int n2)
{
int x,y,u;
x=n1,y=n2;
while(n1!=n2)
{
if(n1>n2)
{
n1=n1-n2;
}
else
{
n2=n2-n1;
}
}
u=(x*y)/n1;
return u;
}
No comments:
Post a Comment