C++ PROGRAMS
This program will help the user get the Least Common Multiple(LCM) of any two numbers entered.
This program also uses simple for-loop.
Code:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,i;
cout<<"Enter any two numbers: ";
cin>>a>>b;
for(i=a;i<=a*b;i+=a)
{
if(i%b==0)
break;
}
cout<<"LCM: "<<i;
getch();
}
Output:
First Run:
Second Run:
For any queries or suggestions please comment.
No comments:
Post a Comment