Hey, here's the latest project I thought up - any suggested improvements?
For some reason cin.get() doesn't work so I fell back on system("PAUSE").Code:#include <iostream> int x; int y; int factors = 0; void factor(); int remainder; int main() { std::cout<<"Type a number and I'll report its factors, if any: "; std::cin>>x; for (y = 1; y <= x; y++) { remainder = x%y; if (remainder == 0 && y != 1 && y != x) factor(); } if (factors == 0) std::cout<<x<<" is a prime number."<<std::endl; system("PAUSE"); return 0; } void factor() { std::cout<<y<<" is a factor of "<<x<<std::endl; ++factors; return; }
FYI I got stuck partway through Accelerated C++ so now I'm reading The C++ Primer by Skinner and Standard C++ Bible by Stevens and Walnum. I still have more ideas than skill!
Thanks for your input -
-JM