1
Modular C Program: GCD & LCM
GCD & LCM using Functions
Presented by : Prajwal S Metri
2
Problem Definition
Develop a modular C program to calculate the Greatest Common Divisor (GCD) and Least Common Multiple (LCM) for two integers, using a separate function.

3
Mathematical Logic
The Euclidean algorithm is efficient for GCD. It states: GCD(a, b) = GCD(b, a % b) until b becomes 0. The GCD is then 'a'. LCM is calculated as: (a × b) / GCD(a, b).

4
Algorithm Process
- Step 1: Define separate functions for GCD and LCM logic.
- Step 2: In main(), input numbers and call the functions.
- Step 3: Print the returned values from gcd() and lcm().
5
C Program Implementation
6
Program Output Examples
Example 1
Input: 12, 18\nGCD: 6\nLCM: 36
Example 2
Input: 10, 25\nGCD: 5\nLCM: 50
7
Summary & Key Takeaways
- ✔ Efficient implementation of Euclidean algorithm.
- ✔ Modular programming improves code cleanliness and reusability.
- ✔ LCM is derived directly from the GCD relationship.
8
Thank You
Modular C Program: GCD & LCM
GCD & LCM using Functions
Presented by : Prajwal S Metri
Made withbobr.ai
1 / 8