C 8
Lab6v2 By zlax on 13th November 2024 08:11:20 AM
  1. #include <stdio.h>
  2. #include <math.h>
  3. int main(void) {
  4.     double a ,b, d, x, x1;
  5.     a=-2;
  6.         b=4;
  7.         d=0.0000000001;
  8.         do {
  9.                 x=(a+b)/2;
  10.                 x1=(x-cos(x))*(a-cos(a));
  11.                 if (x1<0) b=x;
  12.                 else a=x;
  13.         } while((b-a)>d);
  14.         x=(a+b)/2;
  15.         printf("%.10f\n",x);
  16. }

Paste is for source code and general debugging text.

Raw Paste

Login or Register to edit or fork this paste. It's free.