Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include<stdio.

h>
#include<math.h>
#include<conio.h>
#define e 0.0001
#define f(x) x*x*x+x*x+x+7
#define df(x) 3*x*x+2*x+1
void main()
{ int i=1;
float x0,x1,h;
float f1,f0,d;
printf("\nenter the value of x0:\n");
scanf("%f",&x0);
do
{ f0=f(x0);
d=df(x0);
h=f0/d;
x1=x0-h;
f1=f(x1);
printf("\niteration no. %d x =%f\n",i,x1);
printf("\nThe value of function: %f\n",f1);
i++;
x0=x1;
}
while(fabs(f1)>e);
printf("\nthe real root of given f(x) is :%f",x1);
printf("\nthe value of function f(x) is :%f",f1);
getch();
}

You might also like