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

Below is the code that you can modify to solve this problem #include <stdio.h> d

ID: 3727401 • Letter: B

Question

Below is the code that you can modify to solve this problem

#include <stdio.h>

double evaluate(double p[], double x, int size) {
   double total = 0;
   int i = 0;
   double exp = 1;
   while(i < size) {
       total += p[i]*exp;
       exp *= x;
       i++;
   }
   return total;
}

int main() {
   double arr[18];
   int size, i, n;
   printf("Enter degree of the polynomial: ");
   scanf("%d", &n);
   i = 0;
   printf("Enter polynomial: ");
   while(i < n+1) {
       scanf("%lf", arr+i);
       i++;
   }
   size = i;
   printf("polynomial is %lf when x = 1 ", evaluate(arr, 1, size));
   printf("polynomial is %lf when x = 3 ", evaluate(arr, 3, size));
   printf("polynomial is %lf when x = -5 ", evaluate(arr, -5, size));
   return 0;
}

Modify your program in 1 above (or write a new C program) to accept three polynomials as in problem 2. Now, compute two new polynomials Pa and P, where P.-P, x P2 and P7=P, XA, Remember, the highest degree of the any of the polynomials that you are given is 17. You must determine what the largest degree of P6 and P can be. Now, evaluate P6(x) and P2(X) for values of x = 2, x = 5 and x = 7. Submit

Explanation / Answer

Figuring out the easiest and simplest solution.

Modifying the evaluate function with two inputs of arrays and two sizes. i.e:

double evaluate(double p1[], double p2[], double x, int size1, int size2)

{ double total = 0;
   int i = 0;
   double exp = 1;
   while(i < size1) {
       total += p1[i]*exp;
       exp *= x;
       i++;
   }

i=0;

exp=1;

while(i < size2) {
       total += p2[i]*exp;
       exp *= x;
       i++;
   }

return total;

}

Largest degree of P6 will be size1+ size2-2; and P7 will be 2*size3-2;

Now, in main program , take the input of three arrays and provide them in the given evaluate function for the respective array and sizes.

All the best,

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote