**LCM of two numbers using functions**

**LCM of two numbers using functions**

Write a C++ program to find LCM of two numbers using functions. Here’s simple program to find LCM of two numbers using functions in C++ Programming Language.

A common multiple is a number that is a multiple of two or more numbers. The common multiples of 3 and 4 are 0, 12, 24, ….

The least common multiple (LCM) of two numbers is the smallest number (not zero) that is a multiple of both.

Here is source code of the C++ program to find LCM of two numbers using functions. The C++ program is successfully compiled and run(on Codeblocks) on a Windows system. The program output is also shown in below.

**SOURCE CODE : :**

**SOURCE CODE : :**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
/* C++ program to find LCM of two numbers using functions */ #include<iostream> using namespace std; void lcm(int,int); int main() { int a,b; cout<<"Enter 1st number :: "; cin>>a; cout<<"\nEnter 2nd number :: "; cin>>b; lcm(a,b); return 0; } //function to calculate l.c.m void lcm(int a,int b) { int m,n; m=a; n=b; while(m!=n) { if(m < n) { m=m+a; } else { n=n+b; } } cout<<"\nL.C.M of [ "<<a<<" ] and [ "<<b<<" ] is :: "<<m<<"\n"; } |

**Output : :**

**Output : :**

1 2 3 4 5 6 7 8 9 |
/* C++ program to find LCM of two numbers using functions */ Enter 1st number :: 2 Enter 2nd number :: 15 L.C.M of [ 2 ] and [ 15 ] is :: 30 Process returned 0 |

Above is the source code for C++ program to find LCM of two numbers using functions which is successfully compiled and run on Windows System.The Output of the program is shown above .

If you found any error or any queries related to the above program or any questions or reviews , you wanna to ask from us ,you may * Contact Us* through our contact Page or you can also comment below in the comment section.We will try our best to reach up to you in short interval.

**Thanks for reading the post….**