In this program we will use for loop to find lcm of the given 3 numbers. So code for the program is given below.
Code for C program to find LCM of the given 3 numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int i, n1, n2,n3,l1,l2,l3,lcm,gcd;
scanf("%d %d %d",&n1,&n2,&n3);
for(i=1;i<=n1&&i<=n2&&i<=n3;i++)
{
if(n1%i==0 && n2%i==0 &&n3%i==0)
{
gcd=i;
}
}
l1=n1/gcd;
l2=n2/gcd;
l3=n3/gcd;
lcm=l1*l2*l3*gcd;
printf("%d",lcm);
return 0;
}
Output
Enter any three positive integers 2 4 6
LCM of two integers is 12