0

```
//PROGRAM TO FIND DERIVATIVE(FIRST AND SECOND)OF POLYNOMIAL FUNCTIONS
#include<iostream.h>
#include<conio.h>
void main()
{
int i,d,coeff[100],degree[100];
clrscr();
cout<<"\nEnter the degree of the polynomial : ";
cin>>d;
for(i=d;i>=0;i--)
{ if(i>1)
{
degree[i]=i;
cout<<"\nEnter the coefficient of x^"<<degree[i]<<" (with sign) : ";
cin>>coeff[i];
}
else if(i==1)
{
degree[i]=i;
cout<<"\nEnter the coefficient of x (with sign) : ";
cin>>coeff[i];
}
else
{
degree[0]=0;
cout<<"\nEnter the constant term (if any) : ";
cin>>coeff[0];
}
}
clrscr();
cout<<"\n 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<<"\n First 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();
for(i=d;i>=0;i--)
{
coeff[i]*=degree[i];
degree[i]-=1;
}
cout<<"\n Second 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();
}
```