//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&&degree[i]!=1)
     {
     if(degree[i])
     cout<<"+"<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<"+"<<coeff[0];
     }
     else if(coeff[i]<0&&degree[i]!=1)
     {
     if(degree[i])
     cout<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<coeff[0];
     }
     else if(coeff[i]!=0&&degree[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&&degree[i]!=1)
     {
     if(degree[i])
     cout<<"+"<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<"+"<<coeff[i];
     }
     else if(coeff[i]<0&&degree[i]!=1)
     {
     if(degree[i])
     cout<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<coeff[i];
     }
     else if(coeff[i]!=0&&degree[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&&degree[i]!=1)
     {
     if(degree[i])
     cout<<"+"<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<"+"<<coeff[i];
     }
     else if(coeff[i]<0&&degree[i]!=1)
     {
     if(degree[i])
     cout<<coeff[i]<<"x^"<<degree[i];
     else
     cout<<coeff[i];
     }
     else if(coeff[i]!=0&&degree[i]==1)
     {
      if(coeff[i]>0)
      cout<<"+"<<coeff[i]<<"x";
      else
      cout<<coeff[i]<<"x";
     }
    }
    getch();
}

This is annoying me, so let me rant a bit on this.

First of all, I think your caps-lock key is defective or something. Writing everything in upper-case letters just makes you look stupid, I'm sure that's not your intent, so you might want to get that fixed.

Second, this forum is not for pasting code, the site for that is pastebin.com. The main purpose of this forum is education and discussion, your post achieves neither. You just post code without even asking a question or for feedback on it, or spurring any kind of discussion.

The code that you posted is not helpful to anyone either. There are many problems with your code:

  • You use an antiquated, non-standard header: <conio.h>.
  • You use the pre-standard header <iostream.h> which should now (since mid-90s) be <iostream>.
  • You use pre-standard code in which the std-namespace doesn't seem to exist.
  • Your main() function should return int, not void, and that's an error on many compilers.
  • You use very old (C89) style of declaring all variables at the start of a function. This is a practice that is highly discouraged now, especially in the C++ realm.
  • Your indentation is horrible.
  • You pack your code very tightly with no spaces in-between things. This makes the code very hard to read, which is really bad for anyone who tries to learn from it, or tries to grade it.
  • You don't have any comments anywhere.
  • You use very short and un-intuitive names for your variables.
  • Your code lacks any kind of functional separation, or data organization.
  • Your code is very inefficient and repetitive.

Grade: FAIL
(if a prof gives you higher than this for that code, then you should question his sanity)

Why did you post this code? Is it just a nasty prank on people who might naively take this code and submit it (or a code heavily inspired from it) for a grade, then getting a nasty surprise when the grade comes back?

Here, we welcome people who have difficulties with specific problems, and we help them solve those problems. We expect them to do most of the work (coding), but we clarify what they have trouble with, and point them in the right direction towards a solution to their problem. What we don't do is use this site as a place to post complete code, nor do we indulge those who come here expecting us to provide them with submission-ready code for their assignments. The reason for that is simple: it doesn't help them or anyone else. If someone is looking to cheat his way into a passing grade by grabbing code from the web, he can easily do so elsewhere, we don't encourage those people to come here for that. But, I think that providing people with the poisonous gift of a free piece of code that is likely to garnish the wrath of their profs is not a good way to "teach them a lesson", if that was the intent of your post.

This question has already been answered. Start a new discussion instead.