Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to find the integrals of a polynomial with C++?. Below is the part of the

ID: 3706044 • Letter: I

Question

I need to find the integrals of a polynomial with C++?. Below is the part of the code I attempted, however it is not correct. I do need to use arrays and loops.

/**
* Computes an indefinite integral for the specified
* polynomial
* @param poly a degree-coefficients array representation of a
* polynomial.
* @param c the constant term
* @return the array representation of the integral of the
* specified
* polynomial with the specified constant term.
*/
double* integrate(double poly[], double c)
//I'm not sure if any part of this is correct
{
   int i;
   int degree = poly[0];
   for (i=1, i >=degree+1, i++)
   
    double *result = new double[degree+1];
   
    return result;
    delete[] result;
}
}

Explanation / Answer

double* integrate(double poly[], double c){
   int i;
   double respoly[];
   double resc = c+1;
   for ( int i = c; i > 0; --i ) {
      respoly[i] = poly[i-1] / static_cast<float>(i);
   }
   return respoly;
}

This above solution works