Tuesday, December 18, 2012

THE FACTORS OF THE NUMBER IN C++


#include<iostream.h>
void main ()
{
int num, fact, gfact;
cout<<"ENTER A NUMBER : ";
cin >> num;
gfact=num/2;
cout<<"THE FACTORS OF " << num << " ARE : " << endl;
for ( fact=1; fact<=gfact; fact=fact+1)
{
if (num%fact==0)
cout << fact << endl;
}
}

No comments: