#include<iostream.h>
class hcflcm
{
private:
int m,n;
public:
void input()
{
cout<<endl<<"Enter one number:";
cin>>m;cin.get();
cout<<endl<<"Enter another number:";
cin>>n;cin.get();
}
void lcm()
{
for(int i=1;int l=1;i<=m;l<=n;++i;++l)
{if((n%l==0)&&(m%i==0))
cout<<i<<'\t';
else
cout<<m*n;
}
}
};
void main()
{
hcflcm h;
h.input();
h.lcm();
return 0;
}
when i compiled this i got an error in the overloaded for loop Please help i have exam tomorrow please respond fast thanks in advance.
Last edited on
actually i did
for(int i=1, l=1;i<=m,l<=n;++i,++l)
its solved but there is output error thanks for replying
What is your compiler? By the look of your code it is not one that fits the current standard.
1. #include <iostream.h> is not current C++ standard, it is deprecated. #include <iostream> is the current standard.
http://stackoverflow.com/questions/214230/iostream-vs-iostream-h-vs-iostream-h
2. void main() is also not the current C++ standard. int main() is the standard.
http://stackoverflow.com/questions/1915659/does-c-standard-prohibit-the-void-main-prototype#1915702