Program:
#include<stdio.h>
int main()
{
int num1, num2,rem=0,lcm,gcd, n1,n2;
printf("Enter Two Numbers:");
scanf("%d%d",&num1,&num2);
n1=num1;
n2=num2;
rem=num1%num2;
while(rem != 0)
{
num1=num2;
num2=rem;
rem=num1%num2;
}
gcd=num2;
lcm=(n1*n2)/gcd;
printf("\n\t-->> GCD of %d and %d is %d", n1,n2,gcd);
printf("\n\t-->> LCM of %d and %d is %d\n",n1,n2,lcm);
}
Expected O/P:
Enter Two Numbers:12
9
-->> GCD of 12 and 9 is 3
-->> LCM of 12 and 9 is 36
0 Comments
Post a Comment