Find LCM of Two Numbers C Program

C Program To Find LCM of Two Numbers

Learn How To Find LCM of Two Numbers in C Programming Language. LCM is an abbreviated form for Least Common Multiple. This Code To Calculate LCM of Two Integers makes use of While Loop, For Loop and Modulus Operator. The Output for the program has been displayed at the bottom.

What is LCM?

A Least Common Multiple (LCM) of Two Integers is the Smallest Number which is a Multiple of Both the Numbers.

Example of LCM

The LCM of 4 and 3 is 12.

Formula To Find LCM of Two Integers

L.C.M = (x*y)/G.C.D

Must Read: Find LCM of N Numbers in C Programming

C Program To Find LCM of Two Numbers using While Loop

Note: In While Loop’s condition while(b>0), you can also use while(b!=0). However, it doesn’t work always.

C Program To Calculate LCM of Integers using For Loop


Learn How To Find LCM of Two Numbers in C Programming Language

In case you find any error in the above C Program Code To Find LCM of Two Numbers or if you have any doubts, let us know about it in the Comment Section below.

Recommended Programs
C Program To Find GCD of Two Integers
C Program To Replace A Character in String
C Code To Find Largest Digit of a Number
Print Map of India in C Programming
Tower of Hanoi Algorithm C Program

Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

4 thoughts on “Find LCM of Two Numbers C Program

  • August 20, 2016 at 2:50 pm

    Thanks for so many methods. Can we find LCM of 2 Numbers using Recursion in C Programming?

    • August 20, 2016 at 2:52 pm

      Yes. Almost all the loops can be efficiently converted into Recursive functions.

  • September 8, 2016 at 4:24 pm

    This is amazing man. I can now convert any For loop into While loop. Thanks for this amazing LCM program.

  • October 5, 2016 at 4:38 pm

    So basically we have to first find gcd and then lcm of the two numbers input by the user.


Join The Discussion