Search:

Submit Article

# Falsi position for particular equation

Posted By: Adalfreddo Fischer     Category: C Programming     Views: 4100

## Code for Falsi position for particular equation in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
#define E 0.001

float f (float x)
{
return (x-exp(x*-1));
}
void main()
{
int ctr,temp,ctr1;
float res,res1;
int p,NO;
float X1=0.00,X2=0.00,prevX3;
float X3,FX1,FX2,FX3;
int co[10];
clrscr();

//For Scanning X1 and X2

printf("\nEnter the Roots:1::");
flushall();
scanf("%f",&X1);

printf("\nEnter the Roots:2::");
flushall();
scanf("%f",&X2);

//Greater than Zero roots

FX1=f(X1);
FX2=f(X2);

if((FX1 * FX2)>0)
{
printf("\nThis is not Proper Approximation");

}

ctr1=0;
clrscr();

printf("\n==========================================================");
printf("\nNO\tX1\tFX1\tX2\tFX2\tX3\tFX3");
printf("\n==========================================================");

do
{

prevX3=X3;

X3 = ((X1*FX2) - (X2*FX1)) / (FX2 - FX1);

FX1=FX2=FX3=0.0;

FX3  = f(X3);
FX1  = f(X1);
FX2  = f(X2);

printf("\n%d\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f\t%.4f",ctr1+1,X1,FX1,X2,FX2,X3,FX3);

if((FX1 * FX3)>0)
{
X1=X3;

}
elseif(FX3 == 0)
{
printf("%.4f",X3);
break;
}
else
{
X2=X3;

}

ctr1++;
}
while(fabs(prevX3-X3)>E);

printf("\n\n\tThe Root:: %.4f",X3);

getch();
}
```
Share:

Didn't find what you were looking for? Find more on Falsi position for particular equation Or get search suggestion and latest updates.

 Adalfreddo Fischer author of Falsi position for particular equation is from Frankfurt, Germany. View All Articles

 Please enter your CommentComment should be atleast 30 Characters.Please put code inside [Code] your code [/Code]. No Comment Found, Be the First to post comment!