No products in the cart.

## C Program to Find LCM of Two Number

**Write a C Program to find lcm of two number ?**

Today, let’s learn how to find LCM of two numbers in **C Programming Language**. But before executing the program, we will see what is LCM.

Least common multiple (LCM) The least common multiple (LCM) of two numbers is the smallest number that they both divide evenly into. In simple language,the smallest positive number that is a multiple of two or more numbers.

for example:

**Code of the C Program to calculate the LCM of two numbers:**

#include

int main()

{

int n1,n2,i,lcm;

printf(“enter the value of n1,n2”);

scanf(“%d %d”,&n1,&n2);

for(i=2;i<=n1 && i<=n2;i++)

{

if(n1%i==0 && n2%i==0)

{

n1=n1/i;

n2=n2/i;

lcm=i;

lcm=lcm*i;

printf(“lcm=%d\n”,lcm);

}

}

printf(“n1=%d,n2%d,lcm=%d\n”,n1,n2,lcm);

return 0;

}

Leave a comment, if you have any querries or doubt.We will try our best to rectify your problem.