by Dinesh Thakur Category: Functions

 

#include <iostream.h>

 #include <math.h>
 #include<conio.h>
 const double acc = 0.00000000001;
 float r1, r, er;
 inline float s(float x)
    {
           return (x * x + 2 * x + 1);
     }
 inline float ds(float x)
    {
          return (2 * x + 2);
    }
 void main()
{       clrscr();
        cout<<"Enter the initial value of root ";
        cin>>r;
        er = 2;
        while(er>acc)
           {
              if(ds(r) == 0)
                goto l1;
                  r1 = r - (s(r)/ds(r));
                 er = fabs(r - r1);
                 r = r1;
            }
                 l1:
                               cout<<" A real root is "<<r<<"\n";
                               getch();
}

finding the real root of an equation by Newton Raphson technique



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Related Articles