WAP to compute the factors of a given number.



#include<iostream.h>
#include<conio.h>
class factor
{
int f;
public:
void fa(int f);
};
void factor::fa(int f)
{
                for(int i=2;i<=(f/2);i++)
                {
                if(f%i==0)
                cout<<i<<endl;
                }
}
void main()
{
clrscr();
factor obj;
int d;
cout<<"enter the number whose factor has to be calculated"<<endl;
cin>>d;
cout<<"the factors of the number entered are"<<endl;
obj.fa(d);
getch();
}


Output:-


Comments