I am having difficulty with this. I do not understand how to writea program that
ID: 3614679 • Letter: I
Question
I am having difficulty with this. I do not understand how to writea program that solves polynomials and what I have is underneath thequestion. I know its not right but can someone help me with thisplease. (you will see I used: (pow) since that means powers and onthe sheet I have it says pow(x,y), but I do not think the way I didit is right). I use double for the x instead of float b/c he wantsus to use double. But can someone assist me please? ThanksQ: Write a function that computes the value of the followingpolynomial:
3x5 + 2x4 - 5x3 - x2+7x -6
Write a program that asks the userto enter a value for x, calls the function to compute the value ofthe
polynomial, and then displays thevalue returned by the function?
________________________________________________________________________________
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void)
{
int p,
double x;
printf ("Enter a value for x: ");
scanf ("%lf", &x);
p = pow(3,5) + pow(2,4) - pow(5,3) + pow(1,2) +pow(7,1) - 6;
printf ("The value of %lf is: ", p);
getch ();
return 0;
}
Explanation / Answer
Please rate I don't know the type of compiler you are using but if you areusing gcc compiler, make sure you type gcc -lm (then the file namefor pow()) #include #include #include int main (void) { double p; double x; printf ("Enter a value for x: "); scanf ("%lf", &x); p = (3 * pow(x,5)) + (2 * pow(x, 4)) - (5 *pow(x, 3)) + (1 * pow(x, 2)) + (7 * pow(x, 1)) - 6; printf ("The value of p is %.2f: ", p); return 0; }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.