Code for Regular Falsi method in C Programming

C code to implement Regular Falsi method .  Compiled in DEV C++

website_caption1

#include<stdio.h>
 #include<conio.h>
 #include<math.h>
 float f(float);
 float f(float x)
 {
       float y;
       y=pow(x,3)+2*x-2; 
       return y;
       }
 main()
 {
 int i=0;
 float a,b,e,x;
 printf("enter the desire accuracy= ");
 scanf("%f",&e);
       do
       {
                printf("enter the values of a : ");
                scanf("%f",&a);
                    printf("enter the values of b : ");
                scanf("%f",&b);  
       }
       while(f(a)*f(b)>0);
       do
       {
                         x=a-(b-a)/(f(b)-f(a))*f(a);
                         if(f(x)*f(a)>0)
                         b=x;
                         else
                         a=x;
                         i=i+1;
                         }
       while(fabs(f(x))>e);
       printf("the values of i and x are : %d,%f",i,x);
       getch();
 }

website_caption1

You might be also interested in :

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s