Table of Contents
C program to find LCM
C program to find LCM : LCM is Least Common Multiple/Lowest Common Multiple is smallest integer which is divided by both the numbers. LCM of 6 and 8 is 24.
Logic to find LCM in C
#include<stdio.h>
int lcm(int a, int b)
{
int l,i;
if(a>b)
{
l = a;
}
else
{
l = b;
}
i=l;
while(1)
{
if(i % a == 0 && i % b == 0)
{
return i;
}
i+=l;
}
}
//itvoyagers.in
int main() {
int x, y;
printf("Enter first number : ");
scanf("%d",&x);
printf("Enter second number : ");
scanf("%d",&y);
printf("LCM of %d and %d is %d",x,y,lcm(x,y));
return 0;
}
Output :
Enter first number : 6
Enter second number : 8
LCM of 6 and 8 is 24
PRACTICALS/PRACTICE PROGRAM IN C
CHECKOUT OTHER RELATED TOPICS
CHECKOUT OTHER QUIZZES
Quizzes on Operator |
Easy Quiz on Operators in C part 1 |
Easy quiz on operators in C part 2 |
Easy quiz on operators in C part 3 |
Quizzes on Loops |
Easy quiz on loops in C part 1 |
Easy quiz on loops in C part 2 |
Easy quiz on loops in C part 3 |
Quizzes on Decision Making Statement |
Easy Quiz On Decision Making Statements Part 1 |
Easy Quiz On Decision Making Statements Part 2 |
Quizzes on String |
Easy quiz on String in C programming part 1 |
Quizzes on Array |
Easy quiz on Array in C programming – part 1 |
5 – Best Java program to convert decimal to binary |
New Quizzes Coming soon.. |
We are aiming to explain all concepts of C in easiest terms as possible.

ITVoyagers
Author