Friday 25 January 2013

Derivative using c++



           #include <iostream>
           #include <conio>
           #include <stdlib>
           char   ch;


           int d[33],a[55],i,c,j,p,n,q,k;
           void main()

           {


           while(1)
           {
            clrscr();
           cout<<"Enter the highest  power of  X \t";cin>>n;
           cout<<"Enter the coefficient of x^n(x^0,x^1,x^2,........x^n) and constant term\n";
           for(i=0;i<=n;i++)
           {
            cin>>a[i];
           }

              q=n;
           for(i=0;i<n;i++)
           {

            j=q;
            d[i]=j*a[i];
            q--;
           }

           cout<<"Your desire derivative is\ndy/dx=\t";
           k=n;
           for(i=0;i<k;i++)
           {
              p=0;
           p=n-1;
            if(i==0)
            {
             cout<<d[i]<<"X^"<<p;
            }

            else
            cout<<"+"<<d[i]<<"x^"<<p;
            n--;
           }


           getch();

                     }

                     }


0 comments:

Post a Comment