Saturday, 19 November 2011

BISECTION PROGRAM IN C

BISECTION PROGRAM IN C


#include<stdio.h>
#include<conio.h>
#include<math.h>
#define f(x) ((x*x*x)-(4*x)-9)

void main()
{
  float x1,x2,x3;
  float ep;

  printf("Enter x1 and x2");
  scanf("%f%f",&x1,&x2);
  printf("Enter ep :");
  scanf("%f",&ep);
  do
  {
    x3=(x1+x2)/2;
    if((f(x1)*f(x3))<0)
      x2=x3;
    else
      x1=x3;
  }
  while((fabs(x1-x2)>ep) && (f(x3)!=0));
  printf("the value of x3 :%f",x3);
  getch();
}

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel