LCM OF TWO NUMBERS
Code :
#include<stdio.h>
int main()
{
int i, num1, num2, max, lcm=1;
printf("---------- FIND LCM OF 2 NUMBERS ----------\n\n");
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("\nLCM of %d and %d = %d\n", num1, num2, lcm);
printf("-------------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment