Search:

Submit Article

# Program of FALSE POSITION METHOD

Posted By: Volker Fischer     Category: C Programming     Views: 45546

## Code for Program of FALSE POSITION METHOD in C Programming

```#include<stdio.h>
#include<conio.h>
#include<math.h>
#define ESP 0.0001
#define F(x) 3*(x) - 1 - cos(x)
void main()
{
float x0,x1,x2,f1,f2,f0;
int count=0;
clrscr();
do
{
printf("\nEnter the value of x0: ");
scanf("%f",&x0);
}while(F(x0) > 0);
do
{
printf("\nEnter the value of x1: ");
scanf("%f",&x1);
}while(F(x1) < 0);
printf("\n__________________________________________________________\n");
printf("\n    x0\t       x1\t x2\t   f0\t   f1\t   f2");
printf("\n__________________________________________________________\n");
do
{
f0=F(x0);
f1=F(x1);
x2=x0-((f0*(x1-x0))/(f1-f0));
f2=F(x2);
printf("\n%f %f %f %f %f %f",x0,x1,x2,f0,f1,f2);
if(f0*f2<0)
{
x1=x2;
}
else
{
x0 = x2;
}
}while(fabs(f2)>ESP);
printf("\n__________________________________________________________\n");
printf("\n\nApp.root = %f",x2);
getch();
}

/* OUT PUT---------Enter the value of x0: -1Enter the value of x1: 1__________________________________________________________    x0         x1        x2        f0      f1      f2__________________________________________________________-1.000000 1.000000 0.513434 -4.540302 1.459698 -0.3307610.513434  1.000000 0.603320 -0.330761 1.459698 -0.0134970.603320  1.000000 0.606954 -0.013497 1.459698 -0.0005270.606954  1.000000 0.607096 -0.000527 1.459698 -0.000021__________________________________________________________App.root = 0.607096*/```
Share:

Didn't find what you were looking for? Find more on Program of FALSE POSITION METHOD Or get search suggestion and latest updates.

 Volker Fischer author of Program of FALSE POSITION METHOD 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!