answersLogoWhite

0


Best Answer
  1. #include
  2. #include
  3. #include
  4. #define ESP 0.001
  5. #define F(x) (x)*(x)*(x) + (x)*(x) + (x) + 7
  6. void

    main(

    )

  7. {
  8. int

    i=

    1

    ;

  9. float

    x0,

    x1,

    x2;

  10. double

    f1,

    f2,

    f0,

    t;

  11. clrscr(

    )

    ;

  12. printf(

    "\n

    Enter the value of x0: "

    )

    ;

  13. scanf(

    "%f"

    ,&

    x0)

    ;

  14. printf(

    "\n

    Enter the value of x1: "

    )

    ;

  15. scanf(

    "%f"

    ,&

    x1)

    ;

  16. printf(

    "\n

    ____________________________________________\n

    "

    )

    ;

  17. printf(

    "\n

    iteration\t

    x0\t

    x1\t

    x2\t

    f0\t

    f1\t

    f2"

    )

    ;

  18. printf(

    "\n

    _____________________________________________\n

    "

    )

    ;

  19. do
  20. {
  21. x2=

    (

    x0+

    x1)

    /

    2

    ;

  22. f0=

    F(

    x0)

    ;

  23. f1=

    F(

    x1)

    ;

  24. f2=

    F(

    x2)

    ;

  25. printf(

    "\n

    %d %f %f %f %lf %lf %lf"

    ,

    i,

    x0,

    x1,

    x2,

    f0,

    f1,

    f2)

    ;

  26. if

    (

    f0*

    f2<

    0

    )

  27. {
  28. x1=

    x2;

  29. }
  30. else
  31. {
  32. x0=

    x2;

  33. }
  34. i++;
  35. }

    while

    (

    fabs(

    f2)

    >

    ESP)

    ;

  36. printf(

    "\n

    ________________________________________\n

    "

    )

    ;

  37. printf(

    "\n

    \n

    App.root = %f"

    ,

    x2)

    ;

  38. getch(

    )

    ;

  39. }
User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Find a c program for Bisection method?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions