c program for regula falsi method for root finding
#include<stdio.h> #include<math.h> //#include<process.h> float f(double x) { return ((x*x*x)-2*x-5); } void main() { float a,b,c,h; printf("\n Enter the lower limit a and upper limit b\n"); scanf("%f%f",&a,&b); if(f(a)*f(b)>0.0) printf("\n Enter the proper values\n"); do { c=b-((b-a)*f(b))/(f(b)-f(a)); if(f(a)*f(c) <0.0) b=c; else a=c; h=b-((b-a)*f(b))/(f(b)-f(a)); } while(fabs(h-c)>0.0001); printf("\n The value of the root is =%f",h); } output Enter the lower linit a and upper limit b a=2 b=3 the value of the root is =2.0945