Home >>c programs >LCM Program in C

**LCM program in C** is basically written to calculate the L.C.M. of two numbers. Let's understand the definition of LCM and understand what it does. The LCM elaborates to Lowest Common Multiple.

The LCM of two integers n1 and n2 is basically the smallest positive integer that is perfectly divisible by both num1 and num2 that simply means that it should not leave a remainder.

Finding the **LCM of two numbers in C** is extremely easy as it involves the two methods that are if-else statement and while and do-while loop. You will find it very easy to derive the **LCM in C** as it is done with the help of various operators.

Here is a **C program to find the LCM of two numbers** that will help you understand the application aspect of it:

#include <stdio.h> int main() { int num1, num2, minNum; printf("Enter your any two positive integer number "); scanf("%d %d", &num1, &num2); minNum = (num1 > num2) ? num1 : num2; while (1) { if (minNum % num1 == 0 && minNum % num2 == 0) { printf("Here is the LCM of %d and %d is %d.", num1, num2, minNum); break; } ++minNum; } return 0; }

Output :

Enter your any two positive integer number 5 10

Here is the LCM of 5 and 10 is 10

Enter your any two positive integer number 5 10

Here is the LCM of 5 and 10 is 10

Output :

Enter your any two positive integer number 3 6

Here is the LCM of 3 and 6 is 6

Enter your any two positive integer number 3 6

Here is the LCM of 3 and 6 is 6

c programs
LCM Program in C
GCD Program in C
strcmp in C
fgets C
C program to check whether number is Perfect Square or not
C Program to convert from decimal to binary
C Program to Convert Fahrenheit to Celsius
C Program to design a TIC TAC TOE game
Write a C Program to design a calculator using switch case
C Program to find class of an IP Address
C Program to generate random numbers within a range
Write a C Program to print table of number from 1 to 20
C Program to design a digital clock
C Program to design Age Calculator
C Program to guess a random number
C Program to check valid date
C Program to convert hexadecimal to integer
C Program to convert String into Hexadecimal
C Program for EMI Calculator
C Program to find Binary Addition and Binary Subtraction
C Program to solve polynomial equation
C Program to store date in an integer variable
C Program to store time in an integer variable
Fibonacci Series in C
Prime Number program in C
Palindrome program in C
Factorial Number Program in C
Armstrong Number Program in C
C Program to reverse number
C Program to swap two numbers
c program to check odd or even
c program to find sum of two numbers
c program to check positive or negative
c program to find sum of even and odd numbers
c program to check vowel or consonant using switch

No Sidebar ads