Home » C program to find LCM of two numbers

C program to find LCM of two numbers

Below is the code to find LCM of two numbers

#include <stdio.h>
int main(){
    int l,c,m;
    printf("Enter first number: ");
    scanf("%d",&l);
    printf("Enter second number: ");
    scanf("%d",&c);
    if(l>c){
        m=l;
    }
    else{
        m=c;
    }
    while(1){
        if(m%l==0 && m%c==0){
            printf("LCM of the numbers is %d",m);
            break;
            
        }m++;
    }
}

Contents

Output:

Enter first number: 3
Enter second number: 5
LCM of the numbers is 15