I made a code that finds all factors of a number, I'm looking for a way to save each factor in its own variable. I'm an absolute newbie at this so it's probably not too difficult. The end goal for me is a program where you can enter the leading coefficient, constant, and multiplicity of a polynomial and it will give you all real zeros.
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
usingnamespace std;
int main()
{
int a, i, o=0;
i = 0;
cout<<"Enter a number:\n";
cin>>a;
cout<<endl;
for (i=1; i<=a; i++)
{
if (a % i == 0)
{
cout << i << " is a factor" << endl;
++o;
}
}
system("pause");
}
I'm looking to save each value of i that returns true for "if (a % i == 0)" to be saved into a different variable (or maybe an array would be better? haven't used them yet :x)