Write a C program to enter two numbers and find LCM (Lowest Common Multiple) using for loop. How to find LCM of two given numbers in C programming. Find LCM of two numbers using loops in C program.

Input num1: 12

Input num2: 30

Output LCM: 60

Also check this program using recursive approach - C program to find LCM using recursion.

Happy coding ;)

**Example:**Input num1: 12

Input num2: 30

Output LCM: 60

Also check this program using recursive approach - C program to find LCM using recursion.

### Required knowledge

Basic C programming, If else, Conditional operator, For loop#### LCM (Lowest Common Multiple)

LCM is the smallest positive integer that exactly divides two or more numbers.**For Example:**LCM of two numbers |

### Program to find LCM

/** * C program to find LCM of any two numbers */ #include <stdio.h> int main() { int i, num1, num2, max, lcm=1; /* * Reads two numbers from user */ printf("Enter any two numbers to find LCM: "); scanf("%d %d", &num1, &num2); max = (num1>num2) ? num1 : num2; i = max; //Loop runs forever while(1) { /* If i is a multiple of both numbers */ if(i%num1==0 && i%num2==0) { lcm = i; break; } i += max; } printf("\nLCM of %d and %d = %d\n", num1, num2, lcm); return 0; }

Output

Enter any two numbers to find LCM: 12

30

LCM of 12 and 30 = 60

30

LCM of 12 and 30 = 60

Happy coding ;)

### You may also like

- Loop programming exercises index.
- C program to find HCF of two numbers.
- C program to check whether a number is divisible by 5 and 11 or not.
- C program to print all factors of number.
- C program to print all Prime factors of a number.
- C program to find factorial of any number.
- C program to print table of any number in proper format.
- C program to print Fibonacci series up to n terms.
- C program to check whether a number is even or odd.
- C program to enter P, T, R and calculate Compound Interest.
- C program to print all Prime numbers between 1 to n.
- C program to print all Armstrong numbers between 1 to n.
- C program to print all Strong numbers between 1 to n.
- C program to print all Perfect numbers between 1 to n.

< code >< pre > -- Your source code -- < /pre >< /code > (Remove spaces from pre and code tags).