I'm making a program which factors a number which is given by a user. I've gotten a way to output the factors using a for statement, but i would like, if possible to isolate the numbers which are given as factors so i can use them at a later time. I'm a C++ noob, so if there is a simple answer to this, don't be afraid to point it out =)
Code:
#include <iostream.h> #include <math.h> using namespace std; int main() { cout<<endl; cout<<" Factor Application - Finding factors of #s"<<endl; cout<<" ------------------------------------------"<<endl; cout<<endl; cout<<endl; cout<<"Y = AX^2 + BX + C"<<endl; cout<<endl; cout<<endl; cout<<"Insert the B value: "; int bvar; cin>>bvar; cout<<endl; cout<<"Factors: "; if(bvar > 1) { for (int i = 10000; i > 0; i--) { int xvar; xvar = ((bvar/i)*(i)); if ( xvar == bvar) { int xyvar[100]; xyvar[100] = (bvar/i); cout<<xyvar[100]<<" "; } } cout<<endl; } cout<<endl; system("PAUSE"); return (0); }
Comment