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
Use Lagrange interpolation to find the polynomial p3(x) of degree 3 or less, that agree with...
Use Lagrange interpolation to find the polynomial p3(x) of degree 3 or less, that agree with the following data: p3(−1) = 3, p3(0) = −4, p3(1) = 5, and p3(2) = −6. Using python to solve
A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x 3...
A third degree polynomial equation (a cubic equation) is of the form p(x) = c3x 3 + c2x 2 + c1x + c0, where x and the four coefficients are integers for this exercise. Suppose the values of the coefficients c0, c1, c2, and c3have been loaded into registers $t0, $t1, $t2, and $t3, respectively. Suppose the value of x is in $t7. Write the MIPS32 instructions that would evaluate this polynomial, placing the result in $t9.
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT