Don't do this:
using namespace std;
See: Why is “using namespace std” considered bad practice?
Its a bad habits you should not get into doing (even for small programs). Bad habits bite you in the butt when you get to larger projects and forget to stop doing them.
There are a couple of things I would do differently. But I can't say you are doing them wrong.
I prefer not to use
unsigned for numeric values.
double polynom(unsigned, double);
There is no way to check that what was passed was not negative. I can easily call this with:
polynom(-1, 2); // Compiler is happy to convert that -1 to a very large
// positive number without an y errors. On the reciving
// side you can not tell if it was an error.
There are very few times when you need the extra bit for larger positive numbers. Any time I have come across this type of case I have just used a larger integer type (not swapped to the unsigned version).
Unsigned values should be reserved for bit masks in user code.
Don't use return in main.
If you don't put a return at the end of
main() then the compiler will automatically plant code to
return 0. So it is not technically needed.
Additionally not using the
return 0 is a way to indicate that your application can never fail. Note:
return 0 indicates a success to the OS and the compiler is planting it by default to indicate successful termination.
So when I see a
return 0 at the end of
main() I also start to scan the rest of
main() to see if there are any other returns (with non zero value) that will indicate the error conditions of the application.
This is fine.
But personally I think the
= sign provides more context.
double currentAdd = x;
double res = 0;
This is so 50/50. Its just that
for() loops can be slightly more compact.
Would not worry too much about it though.