// Sequential search for roots of sine(x)
// over the range 0 < x < 2 pi radians in steps of 0.0001 radians
#include <iostream>
#include <cmath>
using namespace std;

int main() {

  double dx=0.0001, x=-dx/2;

  do {

    if ( sin(x)*sin(x+dx) < 0 )
      cout << "A root is found near x=" << x+dx/2 << endl;

    x = x+dx;

  } while (x < 2*M_PI);

}
