Program of LCM of a number in C Plus Plus (C++) and C with flowchart
In this tutorial, we will learn about the followings;
- Flowchart of a program of LCM of a number
- Program of LCM of a number in C Plus Plus (C++)
- Program of LCM of a number in C
Flowchart of a program of LCM of a number

Program of LCM of a number in C Plus Plus (C++)
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 | #include<iostream> #include<conio.h> using namespace std; void lcm(int,int); int main() { int p,q; cout<<"Enter two numbers: "; cin>>p; cin>>q; lcm(p,q); getch(); } void lcm(int p,int q) { int i,j; i=p; j=q; while(i!=j) { if(i < j) { i=i+p; } else { j=j+q; } } cout<<"\nL.C.M of two number p="<<p<<" and q="<<q<<" is "<<i; } |
Output

Program of LCM of a number in C
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 | #include<stdio.h> #include<conio.h> void lcm(int,int); int main() { int p,q; printf("Enter two numbers: "); scanf("%d %d",&p,&q); lcm(p,q); getch(); } void lcm(int p,int q) { int i,j; i=p; j=q; while(i!=j) { if(i < j) { i=i+p; } else { j=j+q; } } printf("\nL.C.M of p= %d and q= %d is: %d",p,q,i); } |
Output
