0

I wrote this code for a homework problem. The question asks for the inputs to be an array representing a polynomial along with the degree of the polynomial and the value of x. Then it has to return the derivative of the polynomial. Until I ask the program to output the derivative it works (maybe not the cleanest, nicest program, but it does what it has to). I'm trying to create an array function to return the derivative but I don't know how to code it properly. What I am trying to say in the function is that the derivative should be i*polynomial*^(i-1), but so far I haven't had any success with that. Here is what I have so far.*

```
#include<iostream>
#include<cmath>
using namespace std;
int drv(int[]);
int main()
{
int total;
cout << "Enter the degrees of polynomials: ";
cin >> total;
int polynomial[total];
for (int i=total; i>=0; i--)
{
cout << "Enter the coefficient for the variable of degree " << i << ": ";
cin >> polynomial[i];
cout << "The term representing the variable of degree " << i << " is " << polynomial[i] << "x^" << i << endl;
}
cout << "The derivative of the entered polynomial is: " << drv(polynomial);
return 0;
}
int drv(int[])
{
```