A modulus return of zero is not the only determing factor for a prime number...9 into 16 returns a non zero modulus, but 9 is not prime. A prime number is one that cannot be divided evenly by any number except one and itself. Take a look at the following example:
CODE
#include <iostream>
using namespace std;
bool isPrime(int factor);
int main(void)
{
int orignum;
cout<<"Please enter an integer value:"<<endl;
cin>>orignum;
for(int i=1;i<=orignum;i++)
{
if((orignum%i)==0 && isPrime(i))
{
cout<<i<<" is a prime factor of "<<orignum<<endl;
}
}
return 0;
}
bool isPrime(int factor)
{
bool retValue = true;
for(int i=1;i<=factor;i++)
{
if(((factor%i)==0) && i!=1 && i!=factor)
retValue = false;
}
return retValue;
}
It looks for prime factors of a number, which is what I assume you are trying to do here.