I have just started programming and i made a program that'll give me all the factors of the number i input
the code is the following
It compiled fine and it the factors showed up but after i run the program a window pops up sayingCode:#include <iostream> using namespace std; int main () { int x,y,z; cout << "Enter a number"; cin >> x; cout << x << " is divisible by " << x << ","; z=x; for (z=z;z>0;z-1) { z=z-1; if ((x%z)==0) { cout << z << ","; } } return 0; }
(Factors.exe has encountered a problem and needs to close. We are sorry for the inconvenience.) (The WXP error window)
what did i do wrong with my code?