Ok in the first instance, using power is plain ugly and inefficient. The typical route for a polynomial in the positive sense, is to do something like this:
int total(0);
int xpow(1);
for(int i=0;i<=degree;i++)
{
total+=coef[i]*xpow;
xpow*=x;
}
You can also do it via an internal bracket expansion: [this is effectively (((coef[N]*x+coef[N-1])*x+coef[N-2])*x+.... )))
]
int total(0);
for(int i=degree;i>0;i--)
{
total+=coef[i];
total*=x;
}
total+=coef[0];
I like the second one slightly more.... but not alot in it. [Note the fact you are counting down in the loop, AND you cannot save a step by initializing the total to coef[0] before the loop. -- I only emphasize the last point as ran a 2000 CPU hour simulation with that bug in it :(. ]
Your display function is wrong because you write coef[0] twice, run the loop for(int i=1;i<degree;i++)
. Note that it is normal to write polynomials high power to constant.
Your multiply: If you want to limit the degree to less than 100, then as well as a warning exit as well. Also have your resized coefs??? in temp do you zero coefs in temp ???
Note: Mike_2000_17 beat me to the post [must learn to type faster], sorry for the repeat, the second version of the evaluation code might be of merit, however.
p.s. Thanks for posting a good first post question to the C++ forum, e.g. code blocks, and sufficient information about your problem and what you have tried.