Wednesday, July 6, 2011

Program to print the Factors of the given number


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int n=0,i=0;
cout<<"Enter the number"<<endl;
cin>>n;
cout<<"The prime factors are"<<endl;
for(i=1;i<=n;i++)
{
 if(n%i==0)
 cout<<i<<endl;
}
getch();
}

No comments:

Post a Comment