Skip to main content

Posts

Showing posts with the label Bi-section Method

Bi-section Method

#include<iostream.h> #include<conio.h>  #define EPSILON 0.01 double fun(double X) { return X*X*X+X*X+9; } void bisection (double a, double b) {    if(fun a*fun b>=0)    {    cout<< "you have not assume righta^b" /n;    return;    }    double c=a;    while ((b-a)>=EPSILON)    {    c=(a+b)/2;    if(fun(c)>=0.01)    brack;    else if(fun(a)*fun(b)<0)              b=c;    else   a=c;    }    cout<< "value of root" <<c;    }    void main( ) {    clrscr( );    double a=-200, b=300;    bisection (a,b);    getch( );    };