# Lcm of two numbers program

#### Lcm of two numbers program in c

``` #include<stdio.h> #include<conio.h> void main() { int num1, num2, i, gcd, lcm; printf("Enter two positive numbers "); scanf("%d %d", &num1, &num2); for (i = 1; i <= num1 && i <= num2; i++) { if (num1 % i == 0 && num2 % i == 0) { gcd = i; } } lcm = (num1 * num2) / gcd; printf("The LCM of two numbers %d and %d is %d.", num1, num2, lcm); getch(); } ```

#### Output

```Enter two positive numbers 12 100 The LCM of two numbers 12 and 100 is 300. ```

#### Lcm of two numbers program in c++

``` #include<iostream> #include<conio.h> using namespace std; class LCM { public: void FindLCM(int num1,int num2) { int gcd,lcm; for (int i = 1; i <= num1 && i <= num2; i++) { if (num1 % i == 0 && num2 % i == 0) { gcd = i; } } lcm = (num1 * num2) / gcd; cout<<"The LCM of two numbers "<<num1<<" and "<<num2<<" is "<<lcm<<"."; } }; void main() { int num1, num2, i, gcd, lcm; cout<<"Enter two positive numbers "; cin>>num1>>num2; LCM l; l.FindLCM(num1,num2); getch(); } ```

#### Output

```Enter two positive numbers 24 36 The LCM of two numbers 24 and 36 is 72. ```

#### Lcm of two numbers program in c#

``` using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LCMProject { class LCM { public void FindLCM(int num1, int num2) { int gcd=0, lcm; for (int i = 1; i <= num1 && i <= num2; i++) { if (num1 % i == 0 && num2 % i == 0) { gcd = i; } } lcm = (num1 * num2) / gcd; Console.WriteLine("The LCM of two numbers "+ num1+" and "+num2 +" is "+lcm+"."); } static void Main(string[] args) { Console.Write("Enter two positive numbers "); int num1 = Convert.ToInt32(Console.ReadLine()); int num2 = Convert.ToInt32(Console.ReadLine()); LCM lcm = new LCM(); lcm.FindLCM(num1, num2); Console.ReadLine(); } } } ```

#### Output

```Enter two positive numbers 72 120 The LCM of two numbers 72 and 120 is 360. ```

#### Lcm of two numbers program in java

``` import java.util.*; class LCM { public void FindLCM(int num1, int num2) { int gcd=0, lcm; for (int i = 1; i <= num1 && i <= num2; i++) { if (num1 % i == 0 && num2 % i == 0) { gcd = i; } } lcm = (num1 * num2) / gcd; System.out.println("The LCM of two numbers "+ num1+" and "+num2 +" is "+lcm+"."); } } class examples { public static void main(String[] args) { LCM lcm=new LCM(); Scanner sc=new Scanner(System.in); System.out.println("Enter the first number"); int num1=sc.nextInt(); System.out.println("Enter the second number"); int num2=sc.nextInt(); lcm.FindLCM(num1, num2); } } ```

#### Output

```Enter the first number 20 Enter the second number 140 The LCM of two numbers 20 and 140 is 140. ```

### Write a comment

Name Email Message