#include<stdio.h>
#include<conio.h>
void gcd(int,int);
void main()
{
int n1,n2;
clrscr();
puts("enter no1 ==>");
scanf("%d",&n1);
puts("enter no2 ==>");
scanf("%d",&n2);
gcd(n1,n2);
getch();
}
void gcd(int n1,int n2)
{ int product,temp,lcm;
product=n1*n2;
while(n1>0)
{
if(n1<n2)
{
temp=n1;
n1=n2;
n2=temp;
}
n1=n1%n2;
}
printf("gcd=%d",n2);/*greatest common diviser(gcd)/(hcf)*/
lcm=product/n2;
printf("\nlcm=%d",lcm);
}
OUTPUT
enter no1 ==>
12
enter no2 ==>
18
gcd=6
lcm=36
Tweet
Comments
Post a Comment