please handle my code to be like this output my code here http://www.mediafire.c
ID: 3766168 • Letter: P
Question
please handle my code to be like this output
my code here
http://www.mediafire.com/view/m145m0ww96tp6xc/my-code.txt
programming language is c++
Write a program to print all the derivative(s) of a polynomial expression (shown below) at point x A An example output is shown above (INPUT FROM USER IN RED) This program prints all the derivatives of a polynomial f(x) Please enter the degree of polynomial: 5 Enter the coefficient for xA5: 5 Enter the coefficient for x4: 3.0 Enter the coefficient for x 3: 0.5 Enter the coefficient for x2: 2 Enter the coefficient for x : 0 Enter the coefficient for x0: 5 f(x) = 5.0(x"5)-30(x®4)+0.5(x^3)+20(x"2)+5(x^0) Enter the value for x: 2.0 t_ I (x)-25.0(x-4)-12.0(x®3)+1 .5(x®2)+4.0(x ) and f-l (2.0) = 3 18.0 f2(x)-100.0(x13)-36.0(x"2)+3.0(x® I )+4.0(x®0) and f2(2.0)-666.0 f-3(x)-300.0(x^2)-72.0(x^1)+3.0(x^0) and f-3(2.0)-1059.0 t_4(x)-600.0(x®1)-72.0(x^0) and f-4(2.0) = 1 128.0 f 5(x) 600.0(x 0) and f 5(2.0) 600.0 0(x 4)+0.5(x 3)+2.0(x2)+5(x*0)Explanation / Answer
Answer :
#include <iostream>
#define MAXSIZE 50
using namespace std;
int main()
{
int array[MAXSIZE];
int i, number, power;
float x, polySum;
cout<<"Please Enter Degree of the polynomial ";
cin>>number;
cout<<"Enter the value of x ";
cin>>x;
cout<<"Enter coefficients "<<number + 1;
for (i = 0; i <= number; i++)
{
cin>>array[i];
}
polySum = array[0];
for (i = 1; i <= number; i++)
{
polySum = polySum * x + array[i];
}
power = number;
cout<<"Given polynomial is: ";
for (i = 0; i <= number; i++)
{
if (power < 0)
{
break;
}
if (array[i] > 0)
cout<<" + ";
else if (array[i] < 0)
cout<<" - ";
else
cout<<" ";
cout<< abs(array[i])<<power--;
}
cout<<"Sum of the polynomial "<< polySum;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.