handle my code to be like this output my code here http://www.mediafire.com/view
ID: 3766181 • Letter: H
Question
handle my code to be like this output
my code here
http://www.mediafire.com/view/m145m0ww96tp6xc/my-code.txt
programming language is c++
if you didn't know how to do that , so don't waste my time and submit wrong answer , I posted this question two times and every time got wrong answer
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
#include<iostream.h>
#include<conio.h>
void main()
{
int i,d,coeff[100],degree[100];
clrscr();
cout<<" Enter the degree of the polynomial: ";
cin>>d;
for(i=d;i>=0;i--)
{ if(i>1)
{
degree[i]=i;
cout<<" Enter the coefficient of x^"<<degree[i]<<": ";
cin>>coeff[i];
}
else if(i==1)
{
degree[i]=i;
cout<<" Enter the coefficient of x:";
cin>>coeff[i];
}
else
{
degree[0]=0;
cout<<" Enter the constant term ";
cin>>coeff[0];
}
}
clrscr();
cout<<" Entered polynomial function , f (x)=";
for(i=d;i>=0;i--)
{
if(coeff[i]>0&°ree[i]!=1)
{
if(degree[i])
cout<<"+"<<coeff[i]<<"x^"<<degree[i];
else
cout<<"+"<<coeff[0];
}
else if(coeff[i]<0&°ree[i]!=1)
{
if(degree[i])
cout<<coeff[i]<<"x^"<<degree[i];
else
cout<<coeff[0];
}
else if(coeff[i]!=0&°ree[i]==1)
{
if(coeff[i]>0)
cout<<"+"<<coeff[i]<<"x";
else
cout<<coeff[i]<<"x";
}
}
getch();
for(i=d;i>=0;i--)
{
coeff[i]*=degree[i];
degree[i]-=1;
}
cout<<" Derivative of function , f'(x)=";
for(i=d;i>=0;i--)
{
if(coeff[i]>0&°ree[i]!=1)
{
if(degree[i])
cout<<"+"<<coeff[i]<<"x^"<<degree[i];
else
cout<<"+"<<coeff[i];
}
else if(coeff[i]<0&°ree[i]!=1)
{
if(degree[i])
cout<<coeff[i]<<"x^"<<degree[i];
else
cout<<coeff[i];
}
else if(coeff[i]!=0&°ree[i]==1)
{
if(coeff[i]>0)
cout<<"+"<<coeff[i]<<"x";
else
cout<<coeff[i]<<"x";
}
}
getch();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.