AD 1
- Back to Home »
- Technology Help »
- How to find LCM of two numbers using C language ?
Posted by : Unknown
Thursday, November 20, 2014
Program Sorce Code:-
Type this code in your compiler. Then Compile and Run. I have used Dev C++.
#include <stdio.h>
void main()
{
int num1, num2, max;
printf("Enter two positive integers: ");
scanf("%d %d", &num1, &num2);
max=(num1>num2)?num1:num2;
while(1)
{
if(max%num1==0 && max%num2==0)
{
printf("\nLCM of %d and %d is %d", num1, num2,max);
break;
}
++max;
}
getch();
}
INPUT:-
Type this code in your compiler. Then Compile and Run. I have used Dev C++.
#include <stdio.h>
void main()
{
int num1, num2, max;
printf("Enter two positive integers: ");
scanf("%d %d", &num1, &num2);
max=(num1>num2)?num1:num2;
while(1)
{
if(max%num1==0 && max%num2==0)
{
printf("\nLCM of %d and %d is %d", num1, num2,max);
break;
}
++max;
}
getch();
}
INPUT:-
OUTPUT:-