Question

In: Computer Science

Task 3: a) A second-degree polynomial in x is given by the expression = + +...

Task 3: a) A second-degree polynomial in x is given by the expression = + + , where a, b, and c are known numbers and a is not equal to 0. Write a C function named polyTwo (a,b,c,x) that computes and returns the value of a second-degree polynomial for any passed values of a, b, c, and x. b) Include the function written in part a in a working program. Make sure your function is called from main() and returns a value to main() correctly. Have main() use a printf statement to display the returned value. Test the function by passing various data to it and verifying the returned value.

C/C+ program

Solutions

Expert Solution

c code snippet:

Text code:

#include<stdio.h>
//function to return the value
int polyTwo(int a,int b,int c,int x)
{
   //return the value of a*x^2+b*x+c
   return a*x*x+b*x+c;  
}
int main()
{
   //Initializing t as 5 to test the program for 5 various datas
   int t=5;
  
   while(t--)
   {
       int a,b,c,x;
       //taking user input for a,b,c,x
       scanf("%d%d%d%d",&a,&b,&c,&x);
       //the returned value of polyTwo function is stored in answer variable
       int answer=polyTwo(a,b,c,x);
       //printing the answer
       printf("The returned polynomial value is:%d\n",answer);
   }
return 0;  
}


output:

Hope the solution is useful and if you have any doubt ,please comment down below.


Related Solutions

Given: Polynomial P(x) of degree 6 Given: x=3 is a zero for the Polynomial above List...
Given: Polynomial P(x) of degree 6 Given: x=3 is a zero for the Polynomial above List all combinations of real and complex zeros, but do not consider multiplicity for the zeros.
Find a polynomial f(x) of degree 3 that has the indicated zeros and satisfies the given...
Find a polynomial f(x) of degree 3 that has the indicated zeros and satisfies the given condition. −5, 1, 2;    f(3) = 48 Find a polynomial f(x) of degree 3 that has the indicated zeros and satisfies the given condition. −3, −2, 0;    f(−4) = 24 Find a polynomial f(x) of degree 3 that has the indicated zeros and satisfies the given condition. −2i, 2i, 5;    f(1) = 40 Find the zeros of f(x), and state the multiplicity of each zero. (Order your...
Find the second-degree Taylor polynomial of f(x)=ln(1+sinx) centered at x=0.
Find the second-degree Taylor polynomial of f(x)=ln(1+sinx) centered at x=0.
For the following exercises, use the given information about the polynomial .. Degree 3. Zeros at x = 4, x = 3, and x = 2. y-intercept at (0, −24).
For the following exercises, use the given information about the polynomial graph to write the equation.Degree 3. Zeros at x = 4, x = 3, and x = 2. y-intercept at (0, −24).
Is there a fourth degree polynomial that takes these values? x 1 -2 0 3 -1...
Is there a fourth degree polynomial that takes these values? x 1 -2 0 3 -1 7 y -2 -56 -2 4 -16 376
Let P(x) be a polynomial of degree n and A = [an , an-1,.... ] Write...
Let P(x) be a polynomial of degree n and A = [an , an-1,.... ] Write a function integral(A, X1, X2) that takes 3 inputs A, X0 and X1 A as stated above X1 and X2 be any real number, where X1 is the lower limit of the integral and X2 is the upper limit of the integral. Please write this code in Python.
Let P(x) be a polynomial of degree n and A = [an , an-1,.... ] Write...
Let P(x) be a polynomial of degree n and A = [an , an-1,.... ] Write a function integral(A, X1, X2) that takes 3 inputs A, X0 and X1 A as stated above X1 and X2 be any real number, where X1 is the lower limit of the integral and X2 is the upper limit of the integral. Please write this code in Python. DONT use any inbuilt function, instead use looping in Python to solve the question. You should...
compute the 2-degree polynomial approximation of f(x)= 3x-e^x^2
compute the 2-degree polynomial approximation of f(x)= 3x-e^x^2
(a) Suppose that f is a polynomial of degree 3 or more. Explain, in your own...
(a) Suppose that f is a polynomial of degree 3 or more. Explain, in your own words, how you would use real zeros of f to determine the open intervals over which f(x) > 0 or f(x) < 0. Be brief and precise. In particular, you need to tell how and where the sign of f changes. (d) Rewrite the expression (cos x)2x in terms of natural base e. 4. Let f(x) = x2 + 5. Find limh-0 f(3+h) -...
Prove the following: Let f(x) be a polynomial in R[x] of positive degree n. 1. The...
Prove the following: Let f(x) be a polynomial in R[x] of positive degree n. 1. The polynomial f(x) factors in R[x] as the product of polynomials of degree 1 or 2. 2. The polynomial f(x) has n roots in C (counting multiplicity). In particular, there are non-negative integers r and s satisfying r+2s = n such that f(x) has r real roots and s pairs of non-real conjugate complex numbers as roots. 3. The polynomial f(x) factors in C[x] as...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT