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;
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

Leave a Comment

Your email address will not be published. Required fields are marked *

Hire a server Expert to resolve the issue Now.

Hire a server Expert to resolve the issue Now.

Resolve this issue in just 5$ from https://serverexpert.io

 

You have Successfully Subscribed!

Open chat