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 bn”);scanf(“%f%f”,&a,&b);if(f(a)*f(b)>0.0)printf(“n Enter the proper valuesn”);do{c=b-((b-a)*f(b))/(f(b)-f(a));if(f(a)*f(c) <0.0)b=c;elsea=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=2b=3the value of the root is =2.0945

Pin It on Pinterest

Open chat