You are on page 1of 1

#include<stdio.

h>
#include<conio.h>
#include<math.h>
#define f(x) x*x*x-4*x-9
#define E 0.0001
void main()
{
float x0,x1,x2,f0,f1,f2,f3,f4,e;
do
{
printf("Enter 2 Guess Values - ");
scanf("%f%f",&x1,&x2);
f1=f(x1);
f2=f(x2);
f3=f1*f2;
}while(f3>0);
do
{
x0=(x1+x2)/2;
f0=f(x0);
f4=f1*f0;
if(f4<0)
x2=x0;
else
x1=x0;
e=fabs((x2-x1)/x2);
}while(e>E);
printf("Root = %f",x0);
getch();
}

You might also like