res = (x > y) ? x : y;
#include <stdio.h>
int main() {
int x, y, res;
printf("Enter two positive integers: ");
scanf("%d %d", &x, &y);
res = (x > y) ? x : y;
while (1) {
if (res % x == 0 && res % y == 0) {
printf("The LCM obtained from %d and %d is %d.", x, y, res);
break;
}
++res;
}
return 0;
}
lcm = findLCM(x, y);
#include <stdio.h>
int findLCM(int x, int y, int res);
int main()
{
int x, y, res;
printf (" \n Enter two positive integers: ");
scanf ("%d %d", &x, &y);
res = (x > y) ? x : y;
int lcm=findLCM(x,y,res);
printf ( " \n The LCM obtained from %d and %d is %d. ", x, y, res);
return 0;
}
int findLCM ( int x, int y, int res)
{
while (1) {
if (res % x == 0 && res % y == 0) {
return res;
break;
}
else{++res;}
}
}
Enter two positive integers: 7
35
The LCM obtained from 7 and 35 is 35.