### C program to implement bisection method in easy way..

bisection method theory

##
**Here we have used a term tolerance value .Tolerance value is the difference between two consecutive **

approximate roots of the equation that can be neglected.
As for example 1.00008 and 1.00004 are two approximate consecutive roots .

.One of them can be answer if there will be tolerance value of 0.00004 or greater otherwise not.

Here we have used a function fabs that returns the absolute double value and also takes double value

as an argument.

```
#include<conio.h>
#include<stdio.h>
#include<math.h>
float F(float x)
{
return x*x*x-x-1;
}
/*
f(0)=-ve
f(1)=-ve here a=1 f(a)
f(2)=+ve and b=2
tolerance value:0.0005
*/
int main()
{
float a,b,c,d;
int i=0;
printf("Enter the interval(a,b) in which the roots of the equation lies::");
scanf("%f %f",&a,&b);
printf("\nEnter the tolerance value::");
scanf("%f",&d);
do{
c=(a+b)/2;
++i;
if(F(a)*F(c)<0)//f(a)<0
{ b=c;
printf("\nValue of a and b in %d iteration is %f and %f",i,a,b);
}
else
{
a=c;
printf("\nValue of a and b in %d iteration is %f and %f",i,a,b);
}
}while(fabs(a-b)>d||F(c)==0);
printf("\nRoot is %f",c);
printf("\nPress any key to exit");
getche();
return 0;
}
```