0

Hi,

I'm learning c++ at the moment and the problem I have is probably very simple.

I wrote some code to calculate prime factors of a given number.

If I define variables as unsigned long, the code compiles and the program runs. If I define variables as double then compiler throws error.

Any help?

thanks

My code is:

```
#include<iostream.h>
int main()
{
unsigned long target;
unsigned long i;
unsigned long module;
unsigned long division;
cout << "enter a number: ";
cin >> target;
for (i=2; i<=target; i++)
{
module= target % i;
if (module == 0)
{
unsigned long mod;
do
{
cout<< i<< ", ";
division= target/i;
target= division;
mod= target % i;
}
while (mod == 0);
}
}
cout<< endl;
return 0;
}
```