69. C Program To find LCM of Given n numbers.
How does this program work?
- This Program is used to find the LCM of a given n numbers.
- Here we used arrays to store the elements in sequence.
- By using the for loop and if condition L.c.m we get the desired LCM.
Here is the code
#include <stdio.h>
int main(void)
{
//Programme to Find the L.C.M of n numbers
int i,n,j,l=0, k=0;
printf("Enter Size of the Numbers\n");
scanf("%d",&n);
int a[100];
printf("Enter Numbers\n");
for(i=1;i<=n;i++)
{
scanf( "%d",&a[i]); //To Scan Number in array
}
for( i=1;l<2;i++)
{
k=0;
for( j=1;j<=n;j++)
{
if(i%a[j]==0)
k++;
}
if(k==n)
{
printf("L.C.M of Numbers%d",i );l=3;
}
}
return 0;
}