# looping help

• 10-24-2004
Kazasan
looping help
Code:

```#include <iostream> using namespace std; void check(double a, double b); void checkepsilon(double eps); computexmid(double& c, double& d, double eps, double& mid); int main() { double xleft = 0; double xright = 0; double epsilon = 0; double mp = 0; double xmid = 0; cout << "Please enter xleft " << endl; cin >> xleft; cout << "Please enter xright" << endl; cin >> xright; check(xleft, xright); cout << "Please enter epsilon" << endl; cin >> epsilon; checkepsilon(epsilon); xmid = computexmid(xleft, xright, epsilon, mp); return 0; } void check(double a, double b) {         if(a > b)                 cout << "Bisection can not be computed (sign error, or xleft is greater than xright)" << endl; } void checkepsilon(double ep) {         double eps = 0;                 if(eps < 0)                 cout << "Error - epsilon must be a positive number" << endl; } computexmid(double& c, double& d, double eps, double& mid) {         do{mid = (0.5 * (c+d));}         while(( d-c) > eps);         {                 if( (d-c) <= eps)                         cout << "x left is " << c << ", x right is " << d << endl;         }         return mid; }```
ok my question is how do i stop computexmid to stop going into infinite loop and return xmid and xleft and xright for me?
incase you're wondering im trying to do besection for my programming homework.
if you need to see clearer pics of what im trying to do, check out this out my assignment.
```do{mid = (0.5 * (c+d));}         while(( d-c) > eps);```