Newton-Raphson

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main (void)
{
	float x1,x2,c=0,e=1;
   clrscr();
   printf("Enter the value of x: ");
   scanf("%f",&x1);
   while(e>=0.0001)
   {
   	x2=x1-(x1*x1-3*x1+2)/(2*x1-3);
      e=fabs((x2-x1)/x2);
      c++;
      x1=x2;
   }
   printf("Ittertation no: %.0f\nAns: %f",c,x2);
   getch();
}

Related posts:

Leave a Reply

Your email address will not be published. Required fields are marked *