write a c program to find LCM of two numbers.
Answers
Answered by
11
Explanation:
#include <stdio.h>
int main()
{ int i, num1, num2, max, lcm=1;
printf("Enter any two numbers to find LCM: ");
scanf("%d%d", &num1, &num2);
max = (num1 > num2) ? num1 : num2;
i = max;
while(1)
{ if(i%num1==0 && i%num2==0)
{
lcm = i;
break;
}
i += max;
}
printf("LCM of %d and %d = %d", num1, num2, lcm);
return 0;
}
Output :
Enter any two numbers to find LCM : 12
30
LCM of 12 and 20 = 60
:))
Similar questions
English,
2 months ago
Computer Science,
2 months ago
Accountancy,
2 months ago
Science,
6 months ago
Hindi,
6 months ago
English,
11 months ago
Math,
11 months ago
Science,
11 months ago