C PROGRAM FOR BISECTION METHOD PURBANCHAL UNIVERSITY
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define EPS 0.000001
#define F(x) log(x)-1
void main()
{
float xn,xp,xm,a,b,c,d;
int count;
begin:
printf("Enter Bracketing Values:\t");
scanf("%f%f",&xn,&xp);
a=F(xn);
b=F(xp);
if((a*b)>0)
{
printf("Entered Values Didnot Bracket The ROOT\n");
goto begin;
}
else
{
count=1;
printf("\ncount\t xn\t\t xp\t\t xm\t\t F(xm)\n");
iteration:
xm=((xn+xp)/2);
c=F(xm);
printf("\n%d\t %f\t %f\t %f\t %f\t", count, xn, xp, xm, F(xm));
if(c==0)
{
printf("\n\nROOT: %f\t", xm);
printf("\nITERATION: %d\t", count);
}
else
{
if(c<0)
xn=xm;
else
xp=xm;
Prepared By
Er. Shree Krishna Khadka
Page 144
d=fabs((xn-xp)/xn);
if(d<EPS)
{
xm=((xn+xp)/2);
printf("\n\nROOT: %f\t", xm);
printf("\nITERATION: %d\t", count);
}
else
{
count=count++;
goto iteration;
}
}
}
}
C PROGRAM FOR BISECTION METHOD PURBANCHAL UNIVERSITY
Reviewed by Unknown
on
April 06, 2018
Rating:
Thank you for your post. This is excellent information. It is amazing and wonderful to visit your site.
ReplyDeleteGme course fees