I've been trying to get this solved but without luck.
All I want to do is to differentiate a polynomial like `P(x) = 3x^3 + 2x^2 + 4x + 5`
At the end of the code, the program should evaluate this function and gives me just the answer. 

The derivative of `P(x)` is `P'(x) = 3*3x^2 + 2*2x + 4*1`. If x = 1, the answer is 17. 
I just don't get that answer no matter how I alter my loop.

```
    /*
    x: value of x in the polynomial
    c: array of coefficients
    n: number of coefficients
    */
        double derivePolynomial(double x, double c[], int n) {
                double result = 0;  
                double p = 1;
                int counter = 1;

                for(int i=n-1; i>=0; i--) //backward loop
                    {
                    result = result + c[i]*p*counter;
                    counter++; // number of power
                    p = p*x;
                }

                return result;
            }

   //Output in main() looks like this

   double x=1.5;
   double coeffs[4]={3,2.2,-1,0.5};
   int numCoeffs=4;

   cout << " = " << derivePolynomial(x,coeffs,numCoeffs) << endl;

```