I really don't get this. I made a (more-or-less) simple program that calculates whether a number between 2 to 2147483647 is prime or not, and if it's not prime, then it will display the prime factors. There must be something wrong with the void printPrimeFactors and I can't find anything logically incorrect, but it doesn't want to display the prime factors. What did I do wrong?
On line 51, you are using the XOR operator, which isn't what you want. You probably want to use the sqrt function supplyed in the <cmath> header file instead. Also, another possibility is that simply too much is being calculated: Try doing some things to speed it up like a predefined prime number table for smallish values or other things like that. Finally, you should probably check for a segmentation fault in printPrimeFactors(), which can be achieved by simply doing a test for if y > 7. Why do you need to store the data in an array anyway? You aren't using it ever again...
Wow, that was fast. Anyways, MiiNiPaa, when I replace the (testNumber) with (x), it ends up displaying prime AND composite factors. Also, NT3, I'll try out the table thingy. Oh, and is it really more efficient to use y > 7 rather than using a limited array?
when you hit return, function will instantly stop executing and return value you provided to the caller. So in your code you had stopped your program before it got chance to check user input