C program for Bisection Method

This is program written in c to find the root of equation using bisection method. You can find root of any equation, just you have to do i...

This is program written in c to find the root of equation using bisection method.
You can find root of any equation, just you have to do is change the equation to other equation of which you want to find on the code...... Have Fun!!!


#include<conio.h>
#include<stdio.h>
#include<math.h>
#define f(x) x*x-4*x-10
#define e 0.0001
void main()
{
float x0,x1,x2,f0,f1,f2,root;
int i=1;
clrscr();
printf("Using Bisection Method to find root of equation X^2-4x-10\n");
printf("Enter value for x1 and x2\n");
a:printf("x1: ");
scanf("%f",&x1);
printf("x2: ");
scanf("%f",&x2);
f1=f(x1);
f2=f(x2);
if((f1*f2)>0)
{
printf("Enter another gueses\n");
goto a;
}
else
{
   printf("\t\tx0\tf0\tx1\tf1\tx2\tf2\n");

 b: x0=(x1+x2)/2;
f0=f(x0);
printf("\nItteration: %d\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f",i,x0,f0,x1,f1,x2,f2);
}
if((f1*f0)<0)
{
x2=x0;
f2=f0;
}
else
{
x1=x0;
f1=f0;
}
if(fabs((x2-x1)/x2)<=e)
{
root=(x1+x2)/2;
printf("\nThe root is %.4f",root);
goto c;
}
else
{       i++;
goto b;
}
c:

getch();
}



Output

COMMENTS

Name

Accident Alert,1,AI,2,Array,1,Aurdino,1,C,2,Computer Graphics,9,Data Science,3,Dataset,1,Decoratot,1,Django,1,ESP32,1,Fixed point/iteration method,1,Greater or smaller,1,html,1,Image Processing,1,JAVA,1,Javascript,22,Machine Learning,1,Matlab,3,Numerical Method,13,OOP,1,Other,3,PHP,1,Point operation,1,Python,11,Raspberry pi,1,Recommendation System,1,Regression,1,Reservation System,1,Robotics,1,Simulation,2,sine wave,1,String Handling Function,1,Web scrap,1,Webpage,1,
ltr
item
COMPUTER PROGRAMMING: C program for Bisection Method
C program for Bisection Method
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJsCa_o9Rj2hbCMtcDfuM6DgRVnMVfzkOUnIwFKUb-tbu9nhMn1iDg5ONuNmaDI6tdKQLG-1oRGhxJYqLldMjOZA5ohKSFgPob4oVqHo1F5lx3kF9zZFE_sc3NdB4ZC2eWcY2O15qq5T1/s320/Screenshot+%252836%2529.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBJsCa_o9Rj2hbCMtcDfuM6DgRVnMVfzkOUnIwFKUb-tbu9nhMn1iDg5ONuNmaDI6tdKQLG-1oRGhxJYqLldMjOZA5ohKSFgPob4oVqHo1F5lx3kF9zZFE_sc3NdB4ZC2eWcY2O15qq5T1/s72-c/Screenshot+%252836%2529.png
COMPUTER PROGRAMMING
https://computerprogram4ru.blogspot.com/2016/06/c-program-for-bisection-method.html
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/
https://computerprogram4ru.blogspot.com/2016/06/c-program-for-bisection-method.html
true
8672391763020279633
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy