#include <stdio.h>
#include <math.h>
float f(float x)
{
float y;
y=((x-5.0)x+16.0)x-80.0;
return(y);
}
float xpoint(float x1,float x2)
{
float y;
y=(x1f(x2)-x2f(x1))/(f(x2)-f(x1));
return(y);
}
float root(float x1,float x2)
{
float x,y;
do
{
x=xpoint(x1,x2);
y=f(x);
if(yf(x1)>0)
{
x1=x;
}
else x2=x;
}
while(fabs(y)>=0.0001);
return(x);
}
main()
{
float x1,x2,y1,y2,x;
do
{
printf("input x1,x2:\n");
scanf("%f%f",&x1,&x2);
y1=f(x1);
y2=f(x2);
}
while(y1y2>=0);
x=root(x1,x2);
printf("A root of equation is %8.4f\n",x);
}