Source code:
//C program to find LCM of two numbers using GCD
#include <stdio.h>
int main()
{
int Num1, Num2, LCM;
printf("Enter two number: ");
scanf("%d %d", &Num1, &Num2);
int a = Num1;
int b = Num2;
int Temp, GCD;
while (Num2 != 0)
{
Temp = Num2;
Num2 = Num1 % Num2;
Num1 = Temp;
}
GCD = Num1;
LCM = (a * b) / GCD;
printf("LCM = %d", LCM);
return 0;
}
Output:
No comments:
Post a Comment