#include
#include
#include
#define fn(x) (x*x*x-3*x*x-x+9)
void main()
{
clrscr();
float x,a,b,y,y1,y2;
cout<<"enter the initial value a&b"<
cin>>a>>b;
y1=fn(a);
y2=fn(b);
if(y1*y2>0)
{
cout<<"invalid interval"<
}
do
{
x=(a+b)/2;
y=fn(x);
if(y1*y<0)
{
b=x;
y2=y;
}
else
{
a=x;
y1=y;
}
}
while(fabs(b-a)>.001);
cout<<"the root of the equation ="<
getch();
}
Copyright © 2026 eLLeNow.com All Rights Reserved.