Saving numbers to variables? Probably simple

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.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
using namespace 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)
Last edited on
Topic archived. No new replies allowed.