Tuesday, November 29, 2011

A C++ program to find out the Prime Factors


#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int fact[20],n,num,c=0,j,k;
cout<<"enter the number: ";
cin>>num;
for(n=1;n<=num/2;n++)
{
if(num%n==0)
{
fact[c]=n;
c++;
}
}
cout<<"The Prime Factores Are As Follow"<<endl;
for(n=0;n<c;n++)
{
k=0;
for(j=1;j<=fact[n];j++)
{
if(fact[n]%j==0)
k++;
}
if(k==2)
cout<<fact[n]<<endl;
}
getch();
}

Note:-
            This program is only for few peoples so don't......................... :-)